Repository navigation
Fix flaky test 02417_load_marks_async with parallel replicas - #123825
devcrafter merged 2 commits into
Conversation
The test checked `ProfileEvents['BackgroundLoadingMarksTasks'] != 0` in the initiator's `system.query_log` row only. Under parallel replicas the table (one part, 123 marks) is a single 128-mark segment that the coordinator assigns to a remote replica; the local replica reads only by stealing from an owner that has not announced yet. When the remote owner's announcement arrives first, the local replica reads nothing, the marks are loaded by the remote replicas' secondary queries, and the initiator row stays 0 because remote profile events are not merged into it. With `parallel_replicas_local_plan = 0` the initiator row is always 0. Sum the counter over `initial_query_id`, which also matches the initiator row, so the result is unchanged without parallel replicas. The secondary queries log `current_database = 'default'`, so filter with `has(databases, currentDatabase())`. Seen in `Stateless tests (arm_binary, ParallelReplicas, s3 storage, sequential)`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review (1 finding).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-11:20261004-043300 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20261004-040600 |
|
Workflow [PR], commit [634c768] Summary: ✅ AI ReviewSummaryThis PR fixes the flaky oracle in Final Verdict
|
| ${CLICKHOUSE_CLIENT} -q "SYSTEM FLUSH LOGS query_log" | ||
|
|
||
| result=$(${CLICKHOUSE_CLIENT} -q "SELECT ProfileEvents['BackgroundLoadingMarksTasks'] FROM system.query_log WHERE event_date >= yesterday() AND event_time >= now() - 600 AND query_id = '${QUERY_ID}' AND type = 'QueryFinish' AND current_database = currentDatabase()") | ||
| # With parallel replicas the marks may be loaded only by the replicas, whose rows have current_database = 'default'. |
There was a problem hiding this comment.
@groeneai The comment is not accurate. It'd be simpler to fix test by pinning parallel_replicas_local_plan=1 for the test query i.e. SELECT * FROM test SETTINGS load_marks_asynchronously=$1 FORMAT Null
There was a problem hiding this comment.
Thanks, I rewrote the comment: 634c768.
Pinning parallel_replicas_local_plan = 1 doesn't close it, though: both CI failures already ran with it (it is not in their client args, and the lane does not randomize it). The local replica does use the local plan, it just gets nothing to read. The table is a single 128-mark segment hashed to replica 1, and the local replica only steals from an owner that has not announced yet (ParallelReplicasReadingCoordinator.cpp#L697). In the #123084 job replica 1 announced 48 microseconds before replica 0's first read request, the coordinator answered replica 0 with 0 marks. Finish: true, and only the two remote rows had BackgroundLoadingMarksTasks (10 and 10, initiator 0).
On a local 3-replica rig your variant (the pin plus the initiator-row check) failed 2/50 randomized runs, both with that same coordinator response. The summed check passed 50/50, with 17 of those runs at 0 on the initiator row.
If you'd rather keep the initiator-row check, the deterministic option is enable_parallel_replicas = 0 on that query, at the cost of this test's parallel-replicas coverage.
The marks can be loaded only by remote replicas when the local replica gets nothing to read: the table is a single segment owned by a remote replica, and the local replica only steals before the owner announces itself. Pinning `parallel_replicas_local_plan = 1` does not avoid that: the CI failures already ran with it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
In the ParallelReplicas configuration the single segment of these tests' tables is read by whichever of the three replicas gets it. When a remote replica reads it, the mark and primary index load counters land on that replica's own query_log row (is_initial_query = 0, current_database = 'default'), which the current_database = currentDatabase() filter drops, so the initiator row shows 0. parallel_replicas_local_plan = 1 does not help: the local plan is used but gets nothing to read. Sum the counters over all rows whose initial_query_id is one of the test's queries, as in 02417_load_marks_async (ClickHouse#123825). All replicas share one server's caches and each load is counted once, so the exact references are unchanged, and nothing changes without parallel replicas. Failing job: 03254_system_prewarm_mark_cache in Stateless tests (arm_binary, ParallelReplicas, s3 storage, sequential) on PR ClickHouse#124862. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The test
02417_load_marks_asyncnow sumsBackgroundLoadingMarksTasksover the initial query and the parallel replicas queries it starts, instead of reading only the initiator'ssystem.query_logrow.Description
Related: #122853 (added the lane)
Related: #123790 (re-land)
The test fails in about 1% of runs in the new
Stateless tests (arm_binary, ParallelReplicas, s3 storage, sequential)lane: job 1, job 2. It expectsProfileEvents['BackgroundLoadingMarksTasks'] != 0in the initiator'squery_logrow.The table has 123 marks, one segment, which the coordinator assigns to a remote replica. The local replica reads only by stealing from an owner that has not announced yet. In both failing jobs a remote replica announced first, so the local replica read nothing. All marks were loaded by the two remote replicas, while the initiator row has 0: remote profile events are not merged into it. With
parallel_replicas_local_plan = 0the initiator row is always 0.The check now sums the counter over
initial_query_id, which also matches the initiator row, so nothing changes without parallel replicas. The replica rows havecurrent_database = 'default', so the filter becomeshas(databases, currentDatabase()).Validation on a master debug binary with the lane's 3-replica config:
parallel_replicas_local_plan = 0: old check 10/10 FAIL (-Ok/+F), new check 10/10 OK;slowdown_parallel_replicas_local_plan_read: the old check failed in exactly the 5/10 runs where the local replica got 0 marks; the new check passed 10/10, 6 of them with 0 local marks;load_marks_asynchronously = 0: the new check returns 0;parallel_replicas_local_plan = 0, 50/50 without parallel replicas.Workflow [PR]
Sync PR [sync-upstream/pr/123825]
Version info
26.10.1.1545-master(included in26.10and later)