in-memory parts: several fixes

This commit is contained in:
Anton Popov 2020-05-29 02:59:13 +03:00
parent d8342e5b12
commit 4769ce7271
6 changed files with 32 additions and 8 deletions

View File

@ -1351,7 +1351,7 @@ void MergeTreeData::clearOldWriteAheadLogs()
auto is_range_on_disk = [&block_numbers_on_disk](Int64 min_block, Int64 max_block) auto is_range_on_disk = [&block_numbers_on_disk](Int64 min_block, Int64 max_block)
{ {
auto lower = std::upper_bound(block_numbers_on_disk.begin(), block_numbers_on_disk.end(), std::make_pair(min_block, -1L)); auto lower = std::lower_bound(block_numbers_on_disk.begin(), block_numbers_on_disk.end(), std::make_pair(min_block, -1L));
if (lower != block_numbers_on_disk.end() && min_block >= lower->first && max_block <= lower->second) if (lower != block_numbers_on_disk.end() && min_block >= lower->first && max_block <= lower->second)
return true; return true;

View File

@ -39,7 +39,7 @@ public:
bool isStoredOnDisk() const override { return false; } bool isStoredOnDisk() const override { return false; }
bool hasColumnFiles(const String & /* column_name */, const IDataType & /* type */) const override { return true; } bool hasColumnFiles(const String & column_name, const IDataType & /* type */) const override { return !!getColumnPosition(column_name); }
String getFileNameForColumn(const NameAndTypePair & /* column */) const override { return ""; } String getFileNameForColumn(const NameAndTypePair & /* column */) const override { return ""; }

View File

@ -49,7 +49,7 @@ size_t MergeTreeReaderInMemory::readRows(size_t from_mark, bool /* continue_read
if (!part_in_memory->block.has(name)) if (!part_in_memory->block.has(name))
continue; continue;
const auto block_column = part_in_memory->block.getByName(name).column; const auto & block_column = part_in_memory->block.getByName(name).column;
if (total_rows_read == 0 && part_rows <= max_rows_to_read) if (total_rows_read == 0 && part_rows <= max_rows_to_read)
{ {
res_columns[i] = block_column; res_columns[i] = block_column;

View File

@ -637,13 +637,16 @@ bool StorageMergeTree::merge(
merger_mutator.renameMergedTemporaryPart(new_part, future_part.parts, nullptr); merger_mutator.renameMergedTemporaryPart(new_part, future_part.parts, nullptr);
DataPartsVector parts_to_remove_immediately; DataPartsVector parts_to_remove_immediately;
for (const auto & part : future_part.parts)
{ {
part->notifyMerged(); auto lock = lockParts();
if (isInMemoryPart(part)) for (const auto & part : future_part.parts)
{ {
modifyPartState(part, DataPartState::Deleting); part->notifyMerged();
parts_to_remove_immediately.push_back(part); if (isInMemoryPart(part))
{
modifyPartState(part, DataPartState::Deleting);
parts_to_remove_immediately.push_back(part);
}
} }
} }

View File

@ -0,0 +1 @@
0 bbb_aaa

View File

@ -0,0 +1,20 @@
-- Test 01266_default_prewhere_reqq, but with in-memory parts
DROP TABLE IF EXISTS t1;
CREATE TABLE t1
(
date Date,
s1 String,
s2 String
) ENGINE = MergeTree() PARTITION BY toYYYYMMDD(date) ORDER BY (date, s1)
SETTINGS index_granularity = 8192, min_rows_for_compact_part = 1000, min_rows_for_wide_part = 1000;
set max_threads=1;
insert into t1 (date, s1,s2) values(today()-1,'aaa','bbb');
alter table t1 add column s3 String DEFAULT concat(s2,'_',s1);
-- insert into t1 (date, s1,s2) values(today(),'aaa2','bbb2');
select ignore(date), s3 from t1 where s2='bbb';
DROP TABLE t1;