Repository navigation
Make the query_id of 03652_threads_count_insert unique - #112853
Conversation
The test built its query_id as 03652_query_id_$RANDOM, drawing 4 times per run from bash's 15-bit $RANDOM (0..32767). When two of the 4 loop iterations draw the same number they share one query_id, and every predicate of the test's system.query_log filter is true of both INSERTs, so the later SELECT returns two rows instead of one. order by ALL prints the smaller first, which is the extra 1 above a 7 seen in CI: 11 of the 13 failures recorded in the last 90 days have that shape, spread over 11 unrelated pull requests. This is a test bug and not a query_log defect. query_id uniqueness is enforced only among concurrently running queries, in ProcessList::insert, and system.query_log is append-only history, so several rows for one query_id are by design. My earlier fix in ClickHouse#106671 tightened this same filter, which lowered the rate but could not help, because each predicate it added is also true of both colliding rows. There is a second collision axis. current_database = currentDatabase() isolates executions only when each execution gets a fresh database, whereas the stress arms pass a fixed --database, so one database serves many executions and a repeat draw from an earlier execution matches as well. The id is now composed from the per-iteration loop variables, which closes the within-run axis by construction with no randomness involved, plus a server-generated UUIDv4, which closes the across-execution axis. The natural failure rate is roughly 1 in 11,000, so the mechanism was proven by forcing the collision rather than by repetition: replacing $RANDOM with a constant makes the test fail deterministically with the same diff class in maximal form, and adding only the loop-variable component makes it pass again. The second axis reproduces with a fixed --database, 1 pass and 2 failures in 3 runs, and passes 5 of 5 with the fix. Two mutations confirm each component is load-bearing. Randomized 50/50 run: 50 OK, 0 FAIL. No blanket no-random-settings tag was added, since the mechanism is independent of the randomizer. One of the 13 failures, on ClickHouse#110015, is a different mechanism: a thread-count shortfall printing 4 instead of 7, with the same line count rather than an extra line. It is deliberately not addressed here and is tracked separately, so the residual rate should fall to about 1 per 90 days rather than to zero. Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review (click to expand)An independent reviewer read the resulting code cold, without the author's write-up, and a
The second model returned no findings on the diff. Claims re-derived independently rather than taken from the author's notes, all confirmed:
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-review-slot-52:20260801-031800 |
|
cc @jkartseva, could you review this? The test built its |
|
Workflow [PR], commit [d7f23be] Summary: ✅ AI ReviewSummaryThis PR makes the Final Verdict✅ No blocking or major issues found in the current version of the PR. |
|
Following up on the out-of-scope note in the validation gate above (row f): I ran the promised Two measurements changed the picture. First, entropy. Most of those siblings use Second, what that implies per file. Counting only pairs of distinct CI history agrees. Across all 38 tests over 90 days there are 707 FAIL or ERROR rows and 109 The second axis this PR closed, a repeat draw matching an earlier execution because the stress So the property that made this test worth fixing, four 15-bit draws and 11 observed collision |
Related: #106671
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
03652_threads_count_insert.shbuilt itsquery_idas03652_query_id_$RANDOM, drawing 4times per run from bash's 15-bit
$RANDOM(0..32767). When two of the 4 loop iterations drawthe same number they share one
query_id, and every predicate of the test'ssystem.query_logfilter is true of both INSERTs, so the later
SELECTreturns two rows instead of one.order by ALLprints the smaller first, which is the extra1above a7seen in CI. This is a test bug,not a
query_logdefect:query_iduniqueness is enforced only among concurrently runningqueries and the log is append-only history, so several rows per
query_idare by design.There is a second collision axis:
current_database = currentDatabase()isolates executionsonly when each gets a fresh database, while the stress arms pass a fixed
--database. The fixcomposes the id from the per-iteration loop variables (closing the within-run axis by
construction, with no randomness) plus a server
generateUUIDv4(closing the across-executionaxis).
Validation. The natural failure is roughly 1 in 11,000, so it was proven by forcing the
collision rather than by repetition: replacing
$RANDOMwith a constant makes the test faildeterministically with the same diff class in maximal form, and adding only the loop-variable
component makes it pass again with zero randomness involved. The second axis reproduces with a
fixed
--databaseand passes 5/5 with the fix. Randomized 50/50 run: 50 OK, 0 FAIL. No blanketno-random-settingstag was added, since the mechanism is independent of the randomizer.https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112680&sha=fa21e1fb571139f9ca1c573fd38bd6232eb50aa5&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20sequential%29
Of the 13 CI failures in the last 90 days, 11 have this collision shape. One (#110015) is a
thread-count shortfall (
7becoming4, not an extra line) and one is aserver diedduringcleanup, so the residual rate should fall to about 1 per 90 days rather than to zero.