Repository navigation
Fix 01666_merge_tree_max_query_limit under parallel replicas - #112385
alexey-milovidov merged 1 commit into
Conversation
The test asserts a per-table concurrency throttle that is keyed on query id: checkLimits -> MergeTreeData::getQueryIdHolder -> insertQueryIdOrThrowNoLock throws TOO_MANY_SIMULTANEOUS_QUERIES (202) once query_id_set.size() reaches max_concurrent_queries. ReadFromParallelReplicas never calls RemoteQueryExecutor::setQueryId, so every secondary read is sent with an empty query id, and Context::setCurrentQueryId generates a random UUID when the received id is empty. With max_concurrent_queries = 1 the long running query that is supposed to occupy the single slot therefore becomes several reads of the same table on the same server, each with a different query id, so it competes against itself and is rejected instead of holding the slot. Nothing holds the slot when the final assertion runs, so it returns code 0 and the test fails with "Expected error code: 202 but got: 0". When the rejection lands before read_rows becomes visible, wait_for_query_to_start instead spins on sum(read_rows) over zero rows, which is the timeout mode recorded in the 2025 blacklist entry. The test was excluded from the ParallelReplicas lane by tests/parallel_replicas_blacklist.txt from January 2025 until ClickHouse#111230 removed the entry, which is what made this reachable. This change pins parallel replicas off for the test's client instead of restoring the entry, so all three 202 assertions keep executing on every lane. Validated on one server in both directions: without the pin 0 of 30 runs match the reference, with the pin 30 of 30 match. On ordinary lanes with randomization enabled, 50/50 pass on local disk and 50/50 on S3 storage with nothing skipped. --enable_parallel_replicas 0 alone is sufficient here; --automatic_parallel_replicas_mode 0 is redundant and is kept only to match the two existing precedents in tests/queries/0_stateless. Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review (2 findings, both addressed; second-model gate: 0 findings)An independent reviewer read the change cold, then a second model re-reviewed the diff.
💡 Second-model gate: 0 findings. It read the changed test, the reference, the two sibling Checks the reviewer ran independently rather than taking from the author:
No blocker was raised. The three |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-review-slot-49:20260729-015200 |
|
cc @devcrafter — could you review this? It pins parallel replicas off for |
Picks up merged ClickHouse#112385, which owns the 01666_merge_tree_max_query_limit flakiness this PR's last CI run reported (ledger rule 3c). All 19 conflicts git reported were spurious. The history is criss-cross: two merge bases (5853d88 and e0b3304) exist because master was merged into this branch twice by the maintainer, so the recursive strategy synthesized a virtual base and diffed against that instead of the real one. Verified for every conflicted path that this branch is byte-identical to 5853d88 (the base that is an ancestor of origin/master), so master's content is the only correct resolution and was taken wholesale. This is also why git merge-tree reported a clean tree for the same pair. Master has not touched any of the three files this branch owns, so the unique diff is unchanged: patch-id cd69a0d9107a29 before and after.
…arity Pulls in the fix for `01666_merge_tree_max_query_limit` under parallel replicas (#112385), which was the only CI failure in this pull request and was failing across hundreds of unrelated pull requests in the same job.
…bject-storage Pulls in the fix for `01666_merge_tree_max_query_limit` under parallel replicas (#112385), which caused the sole red in https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100371&sha=c7ac0373b4a7ac469e72b9aea9b3b505a3e05fd0
The re-run of this PR's workflow (attempt 2 of run 30397395779, created 2026-07-28) checks out refs/pull/112265/merge as it stood then, so the tested tree was this head merged with master at 71ec9af (2026-07-28 19:52 UTC). That tree predates c5b976c (PR ClickHouse#112385, merged 2026-07-29 14:35 UTC), which pins --enable_parallel_replicas 0 in 01666_merge_tree_max_query_limit.sh. Without that pin the holder query becomes several reads of the same table on the same server and is rejected by its own max_concurrent_queries = 1 slot, so the last throttle assertion sees no holder. Merging master brings the pin onto the branch, so the outcome no longer depends on which merge base CI picks. Pinned master: 6764095
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Related: #111230. Found by CI triage on #108091.
01666_merge_tree_max_query_limitfails onStateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel), including on master (86d92d6b4119f54a,71ec9afe6fed1be8, bothFailed 3 out of 3 reruns), withExpected error code: 202 but got: 0. It became reachable on that lane when #111230 removed its entry fromtests/parallel_replicas_blacklist.txt; the entry dated from January 2025 with the reason!!!Reason: Timeout!.Root cause: the throttle the test asserts is a per-table counter keyed on query id (
checkLimits->getQueryIdHolder->insertQueryIdOrThrowNoLock).ReadFromParallelRemoteReplicasStep::createPipeForSingeReplicabuilds each secondaryRemoteQueryExecutorwithout callingsetQueryId, so the query id is sent empty andContext::setCurrentQueryIdturns it into a random UUID. Withmax_concurrent_queries = 1the long running query that should hold the single slot becomes several differently-keyed reads of the same table on the same server, so it competes against itself and is rejected instead of holding the slot, and the last assertion gets code 0.system.query_logshows two secondary reads of the holder's own statement rejected with 202, then the holder itself, within 204 ms. If that lands beforeread_rowsis visible,wait_for_query_to_startinstead spins onsum(read_rows)over zero rows, which is the recorded timeout mode.ReadFromParallelReplicasStepomitssetQueryIdthe same way.The fix pins parallel replicas off for the test's client, so all three 202 assertions keep running on every lane. It neither restores the blacklist entry nor undoes #111230, which was right for the other 13 tests it removed. A parallel-replicas-coherent engine throttle would be a separate change.
Validation, one server, both directions: unpinned 0/30 runs match the reference (4
202 but got: 0, 21 hang, 5 other); pinned 30/30. With randomization on, 50/50 pass on local disk and 50/50 on S3, 0 skipped in either.--enable_parallel_replicas 0alone suffices;--automatic_parallel_replicas_mode 0is redundant here, kept to match03164_selects_with_pk_usage_profile_event.shand03518_key_condition_binary_search.sh.