Repository navigation
Fix incorrect result with partitioned GROUP BY - #104869
Merged
alexey-milovidov merged 7 commits intoMay 19, 2026
Merged
Conversation
Contributor
|
Workflow [PR], commit [904575d] Summary: ✅ AI ReviewSummaryThis PR fixes incorrect results in partition-independent aggregation by validating only actual partition or sharding key output nodes (instead of all DAG outputs including source Final VerdictStatus: ✅ Approve |
This was referenced May 17, 2026
alexey-milovidov
approved these changes
May 17, 2026
Contributor
LLVM Coverage Report
Changed lines: 100.00% (15/15) | lost baseline coverage: 2 line(s) · Uncovered code |
yariks5s
approved these changes
May 19, 2026
alexey-milovidov
added a commit
to BoloniniD/ClickHouse
that referenced
this pull request
May 20, 2026
libfuzzer arms `setitimer(ITIMER_REAL)` with an interval of `UnitTimeoutSec / 2 + 1` seconds (11 s for our 20 s timeout), so SIGALRM fires periodically — not only at the actual timeout. The wrapper handler in `clickhouse_fuzzer.cpp` had three issues that together produced spurious "timeout after 21 seconds" failures (seen on PRs ClickHouse#99740 and ClickHouse#104869): 1. SIGALRM has no per-thread routing. The handler is installed process-wide via `sigaction`, so the kernel can deliver it to either the libfuzzer main thread or the runner thread. When it landed on the runner, `fuzzerSigalrmHandler` `pthread_kill`'d SIGUSR1 to itself and raced with a concurrent invocation on the main thread, with two competing `sigaction` restores corrupting handler state. 2. The slow runner-stack dump (shells out to llvm-symbolizer) ran on every periodic SIGALRM, even when the iteration was nowhere near its timeout. The dump alone takes many seconds; combined with the 3-second wait-for-stack window it could push an otherwise-fast iteration past the 20 s limit and trigger a real timeout. 3. The wrapper permanently restored libfuzzer's original handler before `raise(SIGALRM)`, making itself one-shot. A periodic SIGALRM at second ~11 consumed the wrapper, so when the genuine timeout fired at second 20 there was no longer any wrapper to dump the runner stack. Fix all three: - Block SIGALRM on the runner thread at the top of `runLibFuzzer` so the wrapper only ever runs on the libfuzzer main thread. - Track per-iteration start time via `clock_gettime(CLOCK_MONOTONIC)` and skip the SIGUSR1 stack-dump unless elapsed ≥ 15 s, so the 11 s periodic alarms pass through without disturbing the runner. Guard with an atomic to keep the dump single-shot per process. - Call libfuzzer's original handler directly (via the saved `sigaction.sa_sigaction` / `sa_handler`) instead of permanently restoring it. The wrapper stays installed and keeps intercepting later alarms. CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104869&sha=4bb6825eb6220feaca31f3d2608dae09d5de7927&name_0=PR&name_1=libFuzzer%20tests ClickHouse#104869 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The following query gives wrong result:
Returns:
But since it's a group by, the first column should be all unique values.
This happens because
allOutputsDependsOnlyOnAllowedNodesskips validation if the partition output column is only an input column; as a result, we can miss cases like the above example. There is no need to do this special input check here because the other overloadallOutputsDependsOnlyOnAllowedNodescan handle it anyway.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix incorrect aggregation result when grouping by a non-injective function of a column that is also the partition key (e.g.
PARTITION BY awithGROUP BY intDiv(a, 2)ora % 2). Values from different partitions that mapped to the same group were not merged, producing duplicate group rows underallow_aggregate_partitions_independently = 1.Version info
26.5.1.847