Repository navigation
Cut the runtime of 04549_virtual_row_distinct_in_order_boundary - #117742
Conversation
The first fixture of this test wrote six unmerged parts of 20000 rows each at index_granularity = 8, i.e. 45000 marks, which is 90% of the file's marks and 94% of the rows it reads. Under a sanitizer build with distributed cache and s3 storage that reaches the 600s per-test-case timeout of tests/clickhouse-test (-t/--timeout, default 600); the test is long-tagged, so the 180s flaky-check gate never applied to it. Scale that fixture down 10x while preserving the granule microstructure the boundary check depends on. Cutting the row count alone would change the number of rows per (CounterID, EventDate) pair relative to index_granularity, so the key cardinality is scaled by the same factor: number % 1000 becomes number % 100 and each part spans 2000 integers instead of 20000. Rows per key pair per part stay at 20 and granules per pair stay at 2.5, both unchanged, and the part count stays 6, so read_in_order_two_level_merge_threshold still selects the preliminary merge. The asserted DISTINCT set size scales with the fixture, 1000 to 100. Fixture 1 keeps the discriminating power it had. Against a build with both virtual-row fixes disabled it returns the same verdict at 2000 rows per part as at 20000, while fixtures 2 to 4, which are untouched, still fail loudly on that build. EXPLAIN PIPELINE and EXPLAIN actions = 1 are structurally identical before and after, with SelectedParts = 6 on both. Whole-file SelectedMarks drop from 64000 to 10000. Co-Authored-By: Claude Opus 5 <[email protected]>
…hanism The previous wording justified `-- Tags: long` by the 180s flaky-check gate. After the fixture shrink the file no longer approaches that gate, so its stated reason argued against the tag. State the mechanism instead: every fixture needs several unmerged parts of small granules, so the file is dominated by mark reads and costs tens of seconds in sanitizer lanes. The tag itself is kept, because dropping it would newly schedule the test in `Fast test` (`--no-long`) and in the llvm-coverage lane. Related: ClickHouse#96978 (comment) Co-Authored-By: Claude Opus 5 <[email protected]>
Every assertion in the file is a results assertion, and each one is satisfied when read-in-order and distinct-in-order do not run at all: the optimized and unoptimized arms of an equality check then become the same plan, and an "assert absent" row is satisfied most easily by nothing happening. So the file could not witness that the mechanism it is named after is still exercised. The two new arms pin it as a pair, differing in exactly one setting, `optimize_distinct_in_order`, whose interaction with the virtual row is the bug: the widened `DISTINCT` read must keep reverse in-order reading with the stale conversion dropped, while the same read without widening must still build one. `ORDER BY CounterID DESC` reads `InReverseOrder`, not `InOrder`, and the label is matched whitespace-insensitively because it prints as `Read type: ` or `ReadType: ` depending on `pretty`. Measured on a debug build. Both arms return 1 as committed, and both flip to 0 under `query_plan_enable_optimizations = 0`, where the reference diff is exactly the two new rows and nothing else: that is the blind state the previous assertions could not see. With both virtual-row fixes disabled the first arm returns 0 while the second is unchanged, so this fixture now discriminates, which it did not do at either size before. `EXPLAIN` is planning-only, so whole-file `SelectedMarks` stay at 10000 and server-side time grows by 4 ms of 147 ms. `04489_virtual_row_disabled_with_final` is the in-family precedent for this shape. `AGENTS.md:147` prefers a new test over extending an existing one and is deliberately not followed here: a separate file would have to duplicate the same six-part fixture and would add suite runtime, which is the opposite of what this change is for. Requested at ClickHouse#96978 (comment) Co-Authored-By: Claude Opus 5 <[email protected]>
The comment said every fixture needs several unmerged parts. Only the first two call `SYSTEM STOP MERGES`; the last two do two inserts each and do not hold their parts unmerged, so for half the file both "several" and "unmerged" overstated. State what is true of all four instead: each reads multiple parts at `index_granularity = 8`, which is why the file is mark-read dominated and still costs tens of seconds in the heaviest sanitizer lanes. Measured on the two fixtures that do not stop merges: 2 active parts at read time and 4 selected parts per read statement, one for each arm of its equality check, identical over five repeats. Requested at ClickHouse#96978 (comment) Co-Authored-By: Claude Opus 5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; four runs, 4 findings, the last
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20260902-163700 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20260902-145300 |
|
Workflow [PR], commit [2dde17b] Summary: ✅ AI ReviewSummaryThis PR reduces the cost of Final Verdict✅ No review findings. |
|
cc @CurtizJ, could you review this? Test-only: scaling the first fixture down 10x in both rows and key cardinality removes 90% of the file's marks while holding the part count, rows per key pair and granules per pair that the read-in-order virtual row path depends on. I also added a paired |
CI finish ledger -
|
| Check / test | Reason | Owner / fixing PR |
|---|---|---|
Stress test (arm_debug) (ERROR, Job failed to produce Result due to a script error or CI runner issue) |
the hung check could not run its own probe. The job log shows clickhouse-test collect_build_flags issuing SELECT value FROM system.build_options WHERE name = 'CXX_FLAGS' and getting HTTPError: Code: 500. Code: 241. DB::Exception: (total) memory limit exceeded: would use 40.96 GiB ... current RSS: 47.07 GiB, maximum: 47.07 GiB. (MEMORY_LIMIT_EXCEEDED), then Hung check failed with exit code 1 at 20:23:04Z. Teardown ran on until the job hit its own limit at 21:09:06Z (The operation was canceled), so praktika never wrote a result, which is why the node reads ERROR with no test attributed. Note this is the server genuinely at its ceiling and not an accounting drift: the would-use figure is BELOW the measured RSS. Not from this diff, which is two files of one stateless test: Stress test (arm_debug) carries this hung-check row on 10 distinct pull requests in 14 d (159 rows over 12 Stress test flavours), and 04549 appears in this job log only in the workflow config echo, never as a failing test |
#116545 is merged and does NOT own this one, so a fix task is created and is investigating at full effort. Its fixing-PR link will be posted here when it opens |
#116545 (mine, merged 2026-08-28T22:25:57Z) made the hung check survive this state, and it IS
present in this tree (1 occurrence of the marker it adds at 049882702b3b, pre-fix control 0), so
rule 3d applies and I am not linking it as the owner. It taught get_processlist_size to count
rows client-side, because server-side aggregation performs a memory limit check the server cannot
pass in this state. The rejection here is at a sibling call site it did not cover,
collect_build_flags, whose query is not an aggregation at all but is still refused once the total
tracker is at RSS. The two open PRs of mine in this area (#112393, #113428) touch
tests/clickhouse-test but change neither this call site nor the retry predicate, so neither is a
repair PR for it.
The praktika report has 0 DROPPED nodes of 171, so the 132 SKIPPED are the ordinary narrow
selection for a test-only diff and not a build-gate cascade: 37 nodes ran and reported OK.
Session id: cron:our-pr-ci-monitor:20260902-220000
|
Update on the I traced the job (100390573972) end to end. The |
|
@groeneai is this PR still needed? |
|
Yes. Measured today. Master still carries the heavy fixture. The last commit to the file is
The per-test cap is unchanged ( #111457 landing would not remove it. It is open (head This branch cuts whole-file Test-only and mergeable on master, no reviewer yet. The two PRs touch the same fixture lines, so whichever lands second needs a small conflict fix; I can rebase whenever. If you would rather have the scale-down inside #111457, say so and I will close this and put the numbers there. |
Brings the branch up to date with origin/master (c8f4e28), which had advanced 10557 commits past the merge base. The merge was clean with no conflicts, and the branch's diff against master is unchanged: the same two test files with identical additions and deletions. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Conflict resolution: - `MergingSortedAlgorithm.cpp`: master only fixed the message whitespace of `checkVirtualRowCoversSortDescription`; this branch removes that check, keep it removed. - `ReadFromMergeTree::requestReadingInOrder`: keep this branch's handling of a re-request (keep the conversion on widening, reject a re-request that would revoke it), drop master's output/input-count based reset from #119195, and keep master's new early return for a prefix longer than the sorting key (#116364). - `04549_virtual_row_distinct_in_order_boundary`: take master's smaller data (#117742), keep this branch's cases, and keep master's EXPLAIN pair but assert that the widened read keeps its virtual row conversion, as this branch intends. - `05153_virtual_row_widened_prefix_constant_order_by` (new on master): the widened read now keeps the one-column conversion, and the results still match the unoptimized read. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Fixing PR for the My earlier note put the lost Result on the teardown, which was wrong. GitHub concluded that job at 20:32:41Z with |
Related: #96978 (comment)
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Requested by @ alexey-milovidov, who saw
[ FAIL ] 600.13 secin a privateamd_msandistributed-cache + s3 lane. The gate isclickhouse-test's-t/--timeout(600 s per test), not the 180 s flaky-check gate, which skipslongtests.The heaviest lane,
Stateless tests (amd_msan, WasmEdge, parallel, 2/3), runs it at 57 s p50 and 155.6 s worst over 455 true-master runs in 21 days, 0 failures: 3.9x margin. The sanitizer is the multiplier (41x); s3 storage under 4%.Mark reads dominate, almost all in fixture 1: six unmerged parts of 20000 rows at
index_granularity = 8, 15006 marks, four scans selecting 60000 of 64000. Scaling rows and key cardinality down 10x together keeps rows per key pair per part at 20, granules per pair at 2.5, parts at 6.EXPLAIN PIPELINEstays byte-identical andactions = 1differs only by the expected 10xGranulesdrop;SelectedPartsstays 6, and with both virtual-row fixes disabled the fixture gives the same verdict at either size while the three untouched fixtures still fail loudly. Two addedEXPLAINassertions pin that shape in the file.On a debug build, whole-file
SelectedMarksdrop 6.4x and server-side time 400 to 148 ms (2.7x); end to end 1.6x to 1.8x: per-run client andINSERToverhead is over half of what remains. I did not reproduce the private lane; since it multiplies per-granule work I expect 2.7x to 6.4x there.The
longtag is now conservative but stays: dropping it would newly schedule it inFast testand one llvm-coverage lane. 26.8 carries the same file; no backport proposed.If not enough: the other three are 61% of what remains, but each is a discriminating arm at its smallest reproducing size, and another 10x on fixture 1 would cut its
DISTINCTset to 10 rows. Your call.Workflow [PR]
Sync PR [sync-upstream/pr/117742]
Version info
26.10.1.353-master(included in26.10and later)