dbms: fixed error [#METR-16457].

This commit is contained in:
Alexey Milovidov 2015-09-16 07:18:16 +03:00
parent 94d6d70310
commit d51404633b
3 changed files with 19 additions and 7 deletions

View File

@ -708,7 +708,7 @@ public:
DataPartsVector renameTempPartAndReplace(MutableDataPartPtr & part, SimpleIncrement * increment = nullptr, Transaction * out_transaction = nullptr);
/** Убирает из рабочего набора куски remove и добавляет куски add. add должны уже быть в all_data_parts.
* Если clear_without_timeout, данные будут удалены при следующем clearOldParts, игнорируя old_parts_lifetime.
* Если clear_without_timeout, данные будут удалены сразу, либо при следующем clearOldParts, игнорируя old_parts_lifetime.
*/
void replaceParts(const DataPartsVector & remove, const DataPartsVector & add, bool clear_without_timeout);

View File

@ -811,6 +811,7 @@ void MergeTreeData::replaceParts(const DataPartsVector & remove, const DataParts
}
/// Иначе кусок будет удалён с диска позже.
}
for (const DataPartPtr & part : add)
{
data_parts.insert(part);
@ -1266,8 +1267,11 @@ void MergeTreeData::addPartContributionToColumnSizes(const DataPartPtr & part)
auto & column_size = column_sizes[column.name];
if (files.count(bin_file_name)) column_size += files.find(bin_file_name)->second.file_size;
if (files.count(mrk_file_name)) column_size += files.find(mrk_file_name)->second.file_size;
if (files.count(bin_file_name))
column_size += files.find(bin_file_name)->second.file_size;
if (files.count(mrk_file_name))
column_size += files.find(mrk_file_name)->second.file_size;
}
}
@ -1283,8 +1287,11 @@ void MergeTreeData::removePartContributionToColumnSizes(const DataPartPtr & part
auto & column_size = column_sizes[column.name];
if (files.count(bin_file_name)) column_size -= files.find(bin_file_name)->second.file_size;
if (files.count(mrk_file_name)) column_size -= files.find(mrk_file_name)->second.file_size;
if (files.count(bin_file_name))
column_size -= files.find(bin_file_name)->second.file_size;
if (files.count(mrk_file_name))
column_size -= files.find(mrk_file_name)->second.file_size;
}
}

View File

@ -288,6 +288,9 @@ BlockInputStreams MergeTreeDataSelectExecutor::read(
LOG_DEBUG(log, "Selected " << parts.size() << " parts by date, " << parts_with_ranges.size() << " parts by key, "
<< sum_marks << " marks to read from " << sum_ranges << " ranges");
if (parts_with_ranges.empty())
return {};
BlockInputStreams res;
if (select.final)
@ -387,7 +390,8 @@ BlockInputStreams MergeTreeDataSelectExecutor::spreadMarkRangesAmongThreads(
const std::size_t total_rows = data.index_granularity * sum_marks;
/// Выставим приблизительное количество строк только для первого источника
static_cast<IProfilingBlockInputStream &>(*res.front()).setTotalRowsApprox(total_rows);
if (!res.empty())
static_cast<IProfilingBlockInputStream &>(*res.front()).setTotalRowsApprox(total_rows);
LOG_TRACE(log, "Reading approx. " << total_rows);
}
@ -526,7 +530,8 @@ BlockInputStreams MergeTreeDataSelectExecutor::spreadMarkRangesAmongThreadsFinal
const std::size_t total_rows = data.index_granularity * sum_marks;
/// Выставим приблизительное количество строк только для первого источника
static_cast<IProfilingBlockInputStream &>(*to_merge.front()).setTotalRowsApprox(total_rows);
if (!to_merge.empty())
static_cast<IProfilingBlockInputStream &>(*to_merge.front()).setTotalRowsApprox(total_rows);
LOG_TRACE(log, "Reading approx. " << total_rows);
}