Repository navigation
Make 02572_system_logs_materialized_views_ignore_errors ordering total - #121183
alexey-milovidov merged 1 commit into
Conversation
The final listing ordered by `event_time_microseconds`, which holds the statement's start time on a `QueryStart` row and its end time on a `QueryFinish` row. The committed reference is statement order, so that key reproduced it only while every finish timestamp compared strictly less than the next statement's start timestamp. Those are two independent clock reads and the only margin between them is one client round trip, so when the margin collapsed the sort was free to emit the other permutation, which is what the failure below shows: identical content, two adjacent rows transposed. `script_query_number` is the client's 1-based statement counter and the QueryFinish log element is a copy of the QueryStart one, so both rows of a statement carry the same value and `type` separates them. In this result set `(script_query_number, type)` is unique per row, so the listing is ordered without reading a clock at all. The reference is unchanged, which is the cheapest proof the ordering semantics were preserved rather than redefined. Failure this fixes, Fast test (arm_darwin): https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=121126&sha=239316397592d4fd59cfac529b039ba88282c3be&name_0=PR&name_1=Fast%20test%20%28arm_darwin%29 ClickHouse#121126
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings; one full pass over the
Severity: 💡 nit. Nothing was deferred. The ordering claims were checked against Session id: cron:clickhouse-review-slot-9:20260920-114000 |
|
Workflow [PR], commit [c47e745] Summary: ✅ AI ReviewSummaryThis PR makes Findings
Final VerdictStatus:
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20260920-110500 |
| where event_date >= yesterday() AND event_time >= now() - 600 AND current_database = currentDatabase() | ||
| order by event_time_microseconds | ||
| -- `script_query_number` is the client's statement counter, the same on a statement's `QueryStart` and `QueryFinish` rows. | ||
| order by script_query_number, type |
There was a problem hiding this comment.
03312_line_numbers.sql still has the same non-total ordering that this PR is fixing here: it emits QueryStart / QueryFinish pairs from system.query_log, sorts them by event_time_microseconds, type, and its reference expects the two rows of statement 1 to stay ahead of statement 2. Once a QueryFinish timestamp ties or overtakes the next QueryStart, the middle pair can transpose there for the same reason 02572 just did.
Since that test already selects script_query_number, please switch it to ORDER BY script_query_number, type in the same change so we do not leave the sibling query_log reference test with the identical latent flake.
There was a problem hiding this comment.
Verified, and the mechanism is real: 03312_line_numbers.sql:11 does order by event_time_microseconds, type, script_query_number is already in its projection, and its reference does depend on cross-statement order, so a tie would transpose the middle pair there for exactly the reason it did here (QUERY_START = 1 sorts ahead of QUERY_FINISH = 2, so statement 2's start would overtake statement 1's finish).
I am not folding it in, on the measurement. Over 180 days 03312 produced 535,754 OK results, and this transposition is not among its failures: of its 31 recorded failures, 4 have extra QueryStart/QueryFinish 3 10 SYSTEM FLUSH LOGS ... rows, 7 have the text_log Ok rows missing, and 20 are non-zero exits (158/159/241) or a runner artifact. In all 11 of those reference diffs the four QueryStart/QueryFinish rows are unchanged context lines, in reference order. The one observed tie is on Fast test (arm_darwin), and 03312 is -- Tags: no-fasttest: it ran there once in 180 days against 23,949 skips, where 02572 executes 23,545 times. So the tie has never been sampled on a platform 03312 actually runs on.
That makes it a latent nit rather than a fix, and widening a PR that is already queued for review is the reviewer's call rather than mine. The change itself would be one line and safe: ascending (script_query_number, type) is (1,1), (1,2), (2,1), (2,2) there, which is the committed reference order. If a reviewer prefers it here, I will add it in one push.
7d5fa47
Related: #121126
Related: #57088
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Order the final listing of
02572_system_logs_materialized_views_ignore_errorsbyscript_query_number, typeinstead ofevent_time_microseconds, so a same-microsecond pair cannot transpose two rows.Description
Fast test (arm_darwin)on #121126 failed with two adjacent rows transposed, identical content. No open issue tracks it; #57088 is closed.order by event_time_microsecondsis not total here: the column holds a statement's start time on itsQueryStartrow and its end time on itsQueryFinishrow (executeQuery.cpp:557-558vs:441-442). The reference is statement order, which that key reproduces only while each finish stamp stays below the next statement's start stamp: two clock reads, one client round trip apart. Appending, typeor, queryonly makes the failure deterministic: both sortdrop table log_proxy_02572; querystartahead ofsystem flush logs query_log; queryfinish, the order observed.system.query_logrecords the statement order itself:script_query_numberis the client's statement counter, the same on a statement's two rows, andtypeseparates those (1 < 2, numeric). The pair is unique per row here (uniqExact= 24 of 24), so the listing no longer reads a clock..referenceis unchanged.One event in 180 days, so I proved the property instead of waiting for it: degrade a clock column to force the tie, shuffle, sort 50 times. The old key gave 50 distinct outputs, none matching
.reference; the new one gave 1, matching on all 50 even with both clock columns destroyed; zeroingscript_query_numberbrings the 50 back, so the probe can fail.The test's two other recorded failures are rows missing from the listing (2026-07-06, 2026-06-02), a
SYSTEM FLUSH LOGSvisibility question rather than an ordering one, so they are out of scope here.01702_system_query_log.sql:137and03312_line_numbers.sql:11carry the same shape with 0 recorded occurrences of this transposition, so they are untouched.script_query_numberexists since 25.2 (2e664a00b7238); a branch cut before that needsquery_start_time_microseconds, type.Flakiness data: CIDB query and result
Four different mechanisms, each read from that row's
test_context_raw:set log_queries=0;pair absentTimeout! Killing process group, macOSCode: 15 DUPLICATE_COLUMN: Virtual column _table already exists, that PR's own changeWorkflow [PR]
Sync PR [sync-upstream/pr/121183]
Version info
26.10.1.315-master(included in26.10and later)