Skip to content

Fix flaky test 03560_parallel_replicas_memory_bound_merging_projection - #107444

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-03560-estimated-time-flaky
Jun 15, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/fix-03560-estimated-time-flaky

Conversation

@groeneai

@groeneai groeneai commented Jun 14, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

Fix flaky 03560_parallel_replicas_memory_bound_merging_projection. It fails intermittently with Code 160 TOO_SLOW:

Estimated query execution time (1198.32 seconds) is too long. Maximum: 600.
Estimated rows to process: 1000000 (291662 read in 349.50 seconds)
While executing MergeTreeSelect(pool: ReadPoolParallelReplicasInOrder, algorithm: InOrder)

The CI test env sets max_estimated_execution_time=600 (tests/config/users.d/limits.yaml). Under randomized settings and slow storage (observed on the amd_tsan, s3 storage shard), the parallel-replicas in-order read starts slowly, so the linear extrapolation in ExecutionSpeedLimits::throttle over-predicts the runtime and aborts before the query finishes. The clickhouse-test randomized-settings minimizer confirms it: 28/28 runs pass with randomization disabled.

This test checks projection plans and results, not execution speed, so the estimated-time guard is irrelevant here. Set max_estimated_execution_time=0 for the test (before the echoOn block, so the reference output is unchanged).

Found on the CI run of #107429 (report); unrelated to that PR's NuRaft change. No related open issue found.

Version info

  • Merged into: 26.6.1.800

The test fails intermittently with Code 160 TOO_SLOW, e.g.:
  Estimated query execution time (1198.32 seconds) is too long. Maximum: 600.
  Estimated rows to process: 1000000 (291662 read in 349.50 seconds)
  While executing MergeTreeSelect(pool: ReadPoolParallelReplicasInOrder, algorithm: InOrder)

The CI test environment sets max_estimated_execution_time=600
(tests/config/users.d/limits.yaml). Under randomized settings and slow
storage (observed on the amd_tsan s3 shard), the parallel-replicas in-order
read starts slowly, so the linear extrapolation in
ExecutionSpeedLimits::throttle over-predicts the total runtime and aborts the
query before it can finish. The clickhouse-test randomized-settings minimizer
confirms it: 28/28 runs pass with randomization disabled.

This test checks projection plans and results, not execution speed, so the
estimated-time guard is irrelevant here. Disable it for the test by setting
max_estimated_execution_time=0. The SET is placed before the echoOn block so
the reference output is unchanged.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

Pre-PR validation gate

# Question Answer
a Deterministic repro? Yes. The guard is reproduced on demand with the canonical pattern: SELECT * FROM numbers(100000000) SETTINGS max_block_size=1, timeout_before_checking_execution_speed=1, max_estimated_execution_time=2, timeout_overflow_mode='throw' -> Code 160 ... Estimated query execution time (455.6 seconds) is too long. Maximum: 2 ... (TOO_SLOW). Same mechanism (ExecutionSpeedLimits::throttle) and message as the CI failure.
b Root cause explained? The test env sets max_estimated_execution_time=600. Randomized settings + slow storage make the parallel-replicas in-order read start slowly; ExecutionSpeedLimits::throttle linearly extrapolates elapsed * total_rows / read_rows (CI: 349.5s over 291662 of 1000000 rows -> est. 1198s > 600) and throws TOO_SLOW before the query finishes.
c Fix matches root cause? Yes. The throw at ExecutionSpeedLimits.cpp is gated on max_estimated_execution_time != 0. Setting it to 0 for this test disables exactly that guard, the source of the false positive. Not a bounds-widening or data-reduction band-aid.
d Test intent preserved / new tests added? Yes. The test verifies projection plans (EXPLAIN/EXPLAIN PIPELINE) and the aggregation result, neither of which involves execution speed. The pinned setting is placed before the echoOn block, so it does not appear in output and the .reference is unchanged. No assertion is weakened.
e Both directions demonstrated? Yes. WITHOUT fix (max_estimated_execution_time=2): TOO_SLOW reproduced as above. WITH fix (=0): the guard is unreachable and the query proceeds. The full test passes 20/20 with randomization enabled; baseline passes.
f Fix is general, not a narrow patch? N/A (flaky test setting fix, not a code bug). The change is scoped to this single test; the engine guard itself is correct and unchanged.

Session id: cron:clickhouse-worker-slot-2:20260614-171700

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @nickitat — could you review this? It pins max_estimated_execution_time = 0 in the test (before the echoOn block, so the reference is unchanged) to stop a false-positive TOO_SLOW abort: under randomized settings + slow storage the parallel-replicas in-order read starts slowly, so the test-env estimated-time guard (600s) over-extrapolates. Confirmed by the clickhouse-test minimizer (28/28 pass without randomization).

@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Jun 14, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f9897e4]

Summary: ✅


AI Review

Summary

This PR scopes a stateless-test stabilization to 03560_parallel_replicas_memory_bound_merging_projection by disabling max_estimated_execution_time before the echoed assertions. The change matches the reported TOO_SLOW path: the test-level SET overrides the CI profile value from tests/config/users.d/limits.yaml, and ExecutionSpeedLimits::throttle skips the estimated-time exception when the setting is 0. I found no high-signal review findings.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jun 14, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.90% 84.90% +0.00%
Functions 92.30% 92.30% +0.00%
Branches 77.30% 77.30% +0.00%

Changed lines: No C/C++ source files changed — skipping uncovered code analysis.

Newly covered by added/modified tests: 329 line(s), 39 function(s) across 121 file(s) · Details

Top files
  • src/AggregateFunctions/TimeSeries/AggregateFunctionTimeseriesLinearRegression.h: 14 line(s), 32 function(s)
  • src/Functions/LeftRight.h: 12 line(s)
  • src/Storages/StorageReplicatedMergeTree.cpp: 9 line(s)
  • src/Functions/FunctionsCodingIP.cpp: 7 line(s)
  • src/Functions/nested.cpp: 7 line(s)

Full report

@alexey-milovidov alexey-milovidov self-assigned this Jun 15, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Jun 15, 2026
Merged via the queue into ClickHouse:master with commit b5fa90e Jun 15, 2026
166 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants