Limit min_marks_for_concurrent_read

This commit is contained in:
Igor Nikonov 2024-08-01 14:21:54 +00:00
parent 936e3d9a21
commit c5a2f3aafb

View File

@ -383,9 +383,12 @@ Pipe ReadFromMergeTree::readFromPoolParallelReplicas(RangesInDataParts parts_wit
/// We have a special logic for local replica. It has to read less data, because in some cases it should
/// merge states of aggregate functions or do some other important stuff other than reading from Disk.
auto multiplier = context->getSettingsRef().parallel_replicas_single_task_marks_count_multiplier;
// avoid using multiplier if min marks to read is already too big (to avoid overflow)
if (pool_settings.min_marks_for_concurrent_read >= std::numeric_limits<Int64>::max())
if (pool_settings.min_marks_for_concurrent_read > std::numeric_limits<Int64>::max())
{
/// limit min marks to read in case it's big, happened in test since due to settings randomzation
pool_settings.min_marks_for_concurrent_read = std::numeric_limits<Int64>::max();
multiplier = 1.0f;
}
if (auto result = pool_settings.min_marks_for_concurrent_read * multiplier; canConvertTo<size_t>(result))
pool_settings.min_marks_for_concurrent_read = static_cast<size_t>(result);
@ -556,9 +559,12 @@ Pipe ReadFromMergeTree::readInOrder(
};
auto multiplier = context->getSettingsRef().parallel_replicas_single_task_marks_count_multiplier;
// avoid using multiplier if min marks to read is already too big (to avoid overflow)
if (pool_settings.min_marks_for_concurrent_read >= std::numeric_limits<Int64>::max())
if (pool_settings.min_marks_for_concurrent_read > std::numeric_limits<Int64>::max())
{
/// limit min marks to read in case it's big, happened in test since due to settings randomzation
pool_settings.min_marks_for_concurrent_read = std::numeric_limits<Int64>::max();
multiplier = 1.0f;
}
if (auto result = pool_settings.min_marks_for_concurrent_read * multiplier; canConvertTo<size_t>(result))
pool_settings.min_marks_for_concurrent_read = static_cast<size_t>(result);