Repository navigation
Sum the adaptive aggregation seal normalization assertion over the three arms - #115204
PedroTadim merged 1 commit into
Conversation
…ree arms 04676_adaptive_aggregation_replicated_argument asserted AdaptiveAggregationSealNormalizations > 0 separately for each of its three argument representations. That counter is incremented in Aggregator::sealPendingChunks only when the batches one producer has buffered together disagree in physical representation at that argument position, which requires three things: at least two batches buffered in one producer, both representations reachable, and one producer holding blocks of both classes. The test pins the settings governing the second condition. The first depends on the staged payload size, since stageChunk publishes a batch as-is above a byte threshold and sealPendingChunks returns before either counter when only one mini chunk is buffered. The third is a read pool and thread scheduling outcome. So a non-zero count for a single query is not an engine guarantee, and the per-arm assertion asserted a property the engine does not promise. It failed on about 1.9% of the runs the test appeared in, 19 times across 19 unrelated pull requests in 14 days, always one line flipping 1 to 0. Randomization is not the cause. The failure reproduces with randomized settings disabled and with enable_lazy_columns_replication 0, the very setting the test pins, so there is nothing to clamp and a no-random-settings tag would hide the flake rather than address it. Summing the counter over the three arms states the property that does hold: the seal normalized somewhere in the query set. The three queries stay separate, so each keeps its own value comparison and its own abort site, and the aggregate sealed chunks assertion, the six value lines and the tags are unchanged. The same LIKE predicate the sealed chunks assertion already uses is reused, and the three log_comment values are kept so per-arm attribution remains available in query_log. What this gives up is the per-run guarantee that every representation exercised the normalization. Across CI runs each arm still does in about 99.4% of runs, and a binary without the normalization fix aborts on whichever position first sees heterogeneity. Validated locally on a debug build: the old form failed 2 of 300 runs in the same interleaved loop where the new form passed 300 of 300; of 600 runs 6 had an arm at zero and all 6 still had a non-zero total; with the normalization loop reverted the new form aborts 20 of 20 with Bad cast from type DB::ColumnReplicated to DB::ColumnVector in sealPendingChunks, so the regression oracle still detects the original defect. 50 runs with randomized settings and 50 without both pass. The test was added by ClickHouse#115034.
Internal second-model review (click to expand)An independent model reviewed this change cold against the diff, the surrounding aggregation
Two accuracy issues found in my own review were corrected before publishing: the failure counts Session id: cron:clickhouse-review-slot-49:20260817-202400 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20260817-192500 |
|
cc @nihalzp, could you review this? It is a test-only change: the adaptive aggregation seal test asserted the normalization counter separately for each of its three argument representations, but that counter only fires when the batches one producer happens to buffer together disagree, so the per-arm form flaked on about 1.6% of runs. This sums the counter over the three arms instead. |
|
Workflow [PR], commit [2772f8a] Summary: ✅ AI ReviewSummaryThis PR changes Final Verdict✅ No new blocking findings. |
b87ee15
Related: #115034
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
04676_adaptive_aggregation_replicated_argument, which I added in #115034, is flaky: as of2026-08-17 20:00 UTC it had failed 22 times across 22 unrelated pull requests against 1341 passes,
roughly 1.6%, and it is still firing. Every failure is one of three assertion lines flipping
1to
0, for example+normalized nullable 0.Sample report
(
Stateless tests (amd_debug, distributed plan, s3 storage, parallel)on #108431).The test asserted
AdaptiveAggregationSealNormalizations > 0separately for each of its threeargument representations. That counter fires in
Aggregator::sealPendingChunksonly when thebatches one producer buffered together disagree at an argument position, which needs two batches
buffered in one producer, both representations reachable, and one producer holding blocks of both
kinds. The test pins only the second; the others are a read pool decision and thread scheduling,
so a non-zero count for a single query is not an engine guarantee. Randomization is not the cause:
it also reproduces with randomization off and with
enable_lazy_columns_replication 0.This sums the counter over the three arms instead, which is the property the engine does
guarantee, and changes nothing else. The three queries stay separate, so each keeps its own value
comparison and its own abort site; the
sealed chunksassertion, the six value lines and the tagsare untouched. Within one run the test no longer proves that every representation reached the
normalization.
04654already asserts the siblingAdaptiveAggregationSealedChunksin aggregate.Validation: in one interleaved loop the old form failed twice while the new form passed 300 of 300.
Of 600 runs, 6 had an arm at zero and all 6 still had a non-zero total. With #115034's fix reverted
the new form aborts 20 of 20 with
Bad cast from type DB::ColumnReplicated to DB::ColumnVectorinsealPendingChunks. 50 runs with randomized settings and 50 without both pass.Workflow [PR]
Sync PR [sync-upstream/pr/115204]