Repository navigation
Revert "Revert the PromQL topk/limitk streaming plan and its shared-subquery materialization" - #114409
Conversation
…ubquery materialization"
|
Workflow [PR], commit [a6ed1e8] Summary: ❌
AI ReviewSummaryThis PR re-lands the streaming PromQL Findings❌ Blockers
Final VerdictStatus: Minimum required actions:
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 433/447 (96.87%) · Uncovered code |
Build profile diff (arm_release)Comparing Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Object file sizes
|
| Object file | Master | PR | Δ |
|---|---|---|---|
src/AggregateFunctions/CMakeFiles/clickhouse_aggregate_functions.dir/TimeSeries/AggregateFunctionTi… |
new | 668.20 KiB | +668.20 KiB |
src/CMakeFiles/dbms.dir/Storages/TimeSeries/PrometheusQueryToSQL/applyLimitAggregationOperator.cpp.o |
184.75 KiB | 157.62 KiB | -27.12 KiB (-14.68%) |
737 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.
Compile time of recompiled translation units
24 translation units recompiled, 101 s compile time in total, 24 of them have a recent master baseline.
|
We also need to merge this PR afterwards: #114261 |
…-114326-revert-promql-topk-streaming-deadlock
| /// The generated SQL relies on `AS MATERIALIZED` to avoid evaluating subqueries referenced more than once | ||
| /// repeatedly (see SQLSubqueryType::MATERIALIZED_TABLE), and that mark has effect only with the setting | ||
| /// `enable_materialized_cte` enabled. Enable it unless the user set it explicitly. | ||
| if (!getContext()->getSettingsRef()[Setting::enable_materialized_cte].changed) |
There was a problem hiding this comment.
With enable_analyzer = 0 / allow_experimental_analyzer = 0 (either from URL parameters or the user's profile), this still does not materialize the shared PromQL subquery on the HTTP path. executeQuery honors that setting, the old analyzer ignores AS MATERIALIZED, and shapes like or / topk fall back to rescanning the shared subquery once per use. The table-function path avoids that because StoragePrometheusQuery::readImpl always goes through InterpreterSelectQueryAnalyzer, so the two PromQL entry points still diverge here unless we also force the analyzer on before executeQuery (the follow-up in #114261).
There was a problem hiding this comment.
🕵 Correct — the HTTP API path with the old analyzer is fixed separately in #114261, which forces the analyzer on for the machine-generated PromQL SQL before executeQuery and adds an integration test asserting on read_rows with enable_analyzer = 0. Per the maintainer's comment on this PR, #114261 is to be merged right after this re-land, keeping this PR a clean revert of the revert.
…t-promql-topk-streaming-deadlock
|
|
||
| const size_t mask_begin = mask_data.size(); | ||
| mask_data.resize_fill(mask_begin + num_steps, 0); | ||
| for (; i != selected.size() && selected[i].first == key; ++i) |
There was a problem hiding this comment.
This collapses duplicate key values only after they have already occupied slots in the per-step heaps. A minimal repro is timeSeriesTopKMasks(2, key, values) over rows (1, [10]), (1, [10]), (2, [9]): step 0 keeps the two key = 1 entries, and this loop then merges them back into one mask row, so the function returns only series 1 even though there are two distinct series with values.
Because the new aggregate is public and documented only as "key identifies the series", duplicate keys need to be rejected while aggregating or merged by key before ranking. As written, the function can return fewer than k distinct series and drop a better distinct key silently.
|
@groeneai help with tests here. Are they related to changes? Link (or implement first) the fixes for all of them in separate PRs. |
…-114326-revert-promql-topk-streaming-deadlock
|
Four distinct reds across the three earlier heads. One is caused by this PR; three are not. The run on the current head 1. This is not noise, and it is not a regression: it is The raw timings show which side dies. Connection 0 is the left/old server (master), connection 1 is the new one: So the new plan runs the query in 0.068 s while master takes ~10 s and then OOMs on a later run. That is expected: Two consequences, both from the harness's own thresholds: I will send a separate PR shrinking the fixture so the pre-PR plan stays inside the per-run budget while the query shapes and the thing being measured are unchanged, and will link it here. Nothing in 2. Chronic trunk bug in skip-index deserialization. The stack is Breadth over 7 days: 79 rows across 68 distinct PRs including 8 true master runs for this sub-signature alone, 297 rows / 207 PRs / 21 master runs for the whole error family. Fixing PR: #112484 (mine, open) -- it changes 3. Result diff of Tracked as #112987; fixing PR #108855 (mine, open). 4. The test itself passed; it failed in Breadth over 14 days for this teardown signature: 283 rows across 272 distinct tests and 17 PRs, 0 master runs -- the incidental-victim pattern. Fixing PR: #113552 (mine, open), which suppresses exactly that top frame. I will re-check the |
|
@groeneai check one more time. |
|
Rechecked at the current head Two of the three unrelated reds re-ran green here: Still failing: 1. I am sending a separate PR that adds 2. Fixes for the two that went green here, in case they come back: |
|
Performance test OOMed on the master build, that's the subject of the PR. |
…ed for in review Drops the standalone test_query_api_analyzer.py and folds test_generated_sql_always_runs_with_analyzer into test_query_api.py, as requested by @vitlibar on the PR. The new test asserts the two settings the generated query ran with, which is what the source change controls. The per-shape read_rows liveness bound the standalone test carried is dropped with it. 04816_promql_shared_subqueries_materialized covers the materialization itself, and it is back on master with ClickHouse#114409. Verified both directions on a debug build: the test passes with the fix (15/15 repeats, and the whole file green under the default, old-analyzer and distributed-plan integration flavours) and fails without it on the assertion under test, reporting '1\t1' != '0\t1'. Co-Authored-By: Claude Fable 5 <[email protected]>
Edited following .claude/skills/edit-changelog/SKILL.md, by hand on a workstation: the editing step of the NightlyChangelog job has been failing its own verification since 2026-08-12, so three raw blocks had accumulated (47 + 84 + 628 entries). Of the 759 raw entries, 482 are integrated into the in-progress 26.8 section and 277 are dropped: - Section 3: the 300 `NOT FOR CHANGELOG / INSIGNIFICANT` entries are dropped, except 41 that describe a user-visible change and are promoted into a real category, among them a server abort on a corrupt `ORC` stripe footer (#114924), `EXPLAIN ANALYZE` for streaming queries (#112445), `SELECT` from `TimeSeries` (#115622), streaming watermarks (#106169), and the `clickhouse-local` CORS overrides (#115129). - Section 2: every revert in the range cancels out inside it, so neither side appears. Two are re-applications: #114912 re-applies the `accurateCastOrDefault` fix, so #109946 keeps its entry with both links and the intervening revert #114911 is gone; #114409 re-applies the PromQL streaming plan, recorded on the #113656 entry. - Section 4: `Build/Testing/Packaging Improvement` keeps the seven entries a user, packager or from-source builder notices (musl `getaddrinfo` and `sched_getcpu`, signed macOS artifacts, Debian packages for release builds only, zstd-compressed Docker layers, `unit_tests_dbms` without the full library set, vendored Rust built with optimizations locally) and drops the CI plumbing. - Sections 5 and 6: bare pull request URLs converted to links, settings put in backticks, four entries rewritten from developer notes into user-visible descriptions, and three moved into `Performance Improvement`. No entry of a strict-retention category was deleted: the job's own `verify_edit` passes on this edit. Not done here, because the release manager does it at release time: the full significance sort, the aggressive merging of sibling pull requests, and the `FIXME` release date and presentation links.
|
Closing the loop on the fixture PR I promised in this thread: I am not sending it, and the copy of Merging this removed the premise of the red. Master now takes the The fixture has been green on master since: 9,822 recorded One fragility worth recording: the fixture is committed at 4000 series, a size only the streaming plan can run, so any future PR that removes that plan again (it was reverted once in #114326 and restored here) will hit the same allocation on whichever arm lacks it. If a guard that does not depend on which plan master carries is wanted, say so and I will send one. |
Reverts #114326
Depends on #113397
Version info
26.8.1.1365(included in26.8and later)