Repository navigation
Replace chassert with diagnostic LOGICAL_ERROR in AggregateFunctionArray - #102868
nikitamikhaylov merged 2 commits into
Conversation
Pre-PR Validation Gate (session: cron:clickhouse-ci-task-worker:20260416-061500)a) Deterministic repro? b) Root cause explained? c) Fix matches root cause? d) Test intent preserved? e) Both directions demonstrated? |
|
cc @Avogar — could you review this? It replaces the bare |
|
Workflow [PR], commit [9e47e65] Summary: ✅ AI ReviewSummaryThis PR replaces a diagnostic ClickHouse Rules
Final Verdict
|
|
@groeneai there is a failure of tidy build: Fix it. |
The assertion `parameters == nested_func->getParameters()` in AggregateFunctionArray has been firing ~4 times per month in CI (AST fuzzer and serverfuzz stress tests), triggered by specific combinator+Array+Nullable mutations that are extremely hard to reproduce locally. The previous chassert (converted from assert() in PR ClickHouse#102856) only provides the expression text with no information about WHAT the parameters actually are. This makes root cause investigation nearly impossible. Replace with an explicit LOGICAL_ERROR exception that logs: - The Array wrapper function name - The nested function name - Both parameter sets with their values and sizes This preserves the invariant check while providing actionable diagnostic information. The next CI occurrence will immediately reveal which code path produces the parameter mismatch. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Split multi-variable declaration into separate statements to satisfy readability-isolate-declaration clang-tidy check. Co-Authored-By: Claude Opus 4.6 <[email protected]>
388326e to
9e47e65
Compare
|
@Avogar Thanks for the review and the approval! Fixed the clang-tidy |
LLVM Coverage Report
Changed lines: 25.00% (5/20) · Uncovered code |
…eSeries*ToGrid functions
The `timeSeries*ToGrid` aggregate function family normalizes its parameters
internally — 4 user-typed literals (start, end, step, window) are stored as
`Decimal64` fields scaled to match the timestamp column, and the 5-parameter
`timeSeriesPredictLinearToGrid` variant stores `predict_offset` as a member
instead of in the parameter array. This produces an intentional normalization
that lets states serialized with different timestamp scales merge together.
When the `Array` combinator wrapped such a function, its constructor fired
`LOGICAL_ERROR` ("parameters mismatch"): it was initializing its own parameter
array from the user-typed `params_` (`UInt64`, possibly 5 entries) but then
comparing against the nested function's normalized parameters (`Decimal64`,
always 4 entries). The assertion was originally a `chassert` that silently
compiled out in release; ClickHouse#102868 made it a real `LOGICAL_ERROR` to aid
diagnosis, which then surfaced as a master-level failure in serverfuzz /
`AST fuzzer` runs (STID 4870 family, ~10 hits across 60 days).
Fix the Array combinator by initializing its own parameter array from
`nested_->getParameters()` instead of the user-supplied `params_`. This makes
the wrapper transparent to whatever normalization the nested function performs:
`timeSeries*ToGridArray(...)` states now match the corresponding
`timeSeries*ToGrid(...)` states, preserving the scale-independent state
compatibility that `timeSeries*ToGrid` relies on.
For every other aggregate function the user-typed `params_` and
`nested_->getParameters()` are identical — no behavior change.
Reproducer (previously threw `LOGICAL_ERROR`, now succeeds):
```
SET allow_experimental_time_series_aggregate_functions = 1;
SELECT timeSeriesPredictLinearToGridArray(60, 180, 10, 20, -60)(ts, val) FROM ts;
SELECT timeSeriesDerivToGridArray(60, 180, 10, 20)(ts, val) FROM ts;
```
Regression test: `04102_timeseries_array_combinator_params`.
STID 4870 family: 4870-4f07, 4870-4f21, 4870-4d73, 5480-49e6.
Diagnostic PR that made the error visible: ClickHouse#102868.
The assertion
parameters == nested_func->getParameters()inAggregateFunctionArrayhas been firing sporadically in CI (~4 hits per month) through AST fuzzer and serverfuzz stress tests (STID 4870-4f21, STID 4870-4e45, STID 2508-522c).The previous
chassert(converted from Cassert()in #102856, before that fixed primary root cause in #100679) only provides the expression text — zero information about what the actual parameters are when it fires. This makes investigation of the remaining secondary code path extremely difficult.What this PR does:
Replaces the
chassertwith an explicitLOGICAL_ERRORexception that logs:quantileIfArrayArray)nothingNull)Example error message:
Why:
The invariant that
parameters == nested_func->getParameters()should always hold because the Array combinator does not transform parameters. When it fails, it indicates a bug inAggregateFunctionFactory::getImpl()or a combinator wrapper that loses/modifies parameters during resolution.The diagnostic info will immediately identify which combinator+function combination triggers the mismatch, enabling targeted root cause analysis on the next CI occurrence.
Behavior:
Changelog category (leave one):
Changelog entry (a]utofill):
...no entry required...
Documentation is written (if applicable)
Version info
26.4.1.1009