Fix: max_execution_time_leaf with parallel replicas

This commit is contained in:
Igor Nikonov 2024-09-11 20:51:28 +00:00
parent 592910d538
commit df0779cd10
3 changed files with 29 additions and 0 deletions

View File

@ -451,6 +451,7 @@ void executeQueryWithParallelReplicas(
auto not_optimized_cluster = context->getClusterForParallelReplicas();
auto new_context = Context::createCopy(context);
const auto & new_settings = new_context->getSettingsRef();
/// check hedged connections setting
if (settings.use_hedged_requests.value)
@ -474,6 +475,14 @@ void executeQueryWithParallelReplicas(
new_context->setSetting("use_hedged_requests", Field{false});
}
if (settings.max_execution_time_leaf.value > 0)
{
/// Replace 'max_execution_time' of this sub-query with 'max_execution_time_leaf' and 'timeout_overflow_mode'
/// with 'timeout_overflow_mode_leaf'
new_context->setSetting("max_execution_time", Field{new_settings.max_execution_time_leaf});
new_context->setSetting("timeout_overflow_mode", Field{new_settings.timeout_overflow_mode_leaf});
}
auto scalars = new_context->hasQueryContext() ? new_context->getQueryContext()->getScalars() : Scalars{};
UInt64 shard_num = 0; /// shard_num is 1-based, so 0 - no shard specified

View File

@ -0,0 +1,20 @@
-- Tags: no-fasttest
DROP TABLE IF EXISTS 03231_max_execution_time_t SYNC;
CREATE TABLE 03231_max_execution_time_t
(
key UInt64,
value String,
)
ENGINE = ReplicatedMergeTree('/clickhouse/{database}/03231_max_execution_time', 'r1')
ORDER BY (key, value);
INSERT INTO 03231_max_execution_time_t SELECT number, toString(number) FROM numbers(100_000_000);
SET allow_experimental_parallel_reading_from_replicas = 2, max_parallel_replicas = 3, parallel_replicas_for_non_replicated_merge_tree=1, cluster_for_parallel_replicas='test_cluster_one_shard_three_replicas_localhost';
SELECT key, SUM(length(value)) FROM 03231_max_execution_time_t GROUP BY key SETTINGS max_execution_time=1; -- { serverError TIMEOUT_EXCEEDED }
SELECT key, SUM(length(value)) FROM 03231_max_execution_time_t GROUP BY key SETTINGS max_execution_time_leaf=1; -- { serverError TIMEOUT_EXCEEDED }
-- Can return partial result
SELECT key, SUM(length(value)) FROM 03231_max_execution_time_t GROUP BY key FORMAT Null SETTINGS max_execution_time=1, timeout_overflow_mode='break';
SELECT key, SUM(length(value)) FROM 03231_max_execution_time_t GROUP BY key FORMAT Null SETTINGS max_execution_time_leaf=1, timeout_overflow_mode_leaf='break';
DROP TABLE 03231_max_execution_time_t SYNC;