Repository navigation
Conversation
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-1:20260711-043400 |
|
cc @KochetovNicolai @Fgrtue — could you review? EXPLAIN ANALYZE's per-step wall-clock feature (#106586) asserts |
|
Workflow [PR], commit [592b987] Summary: ❌
|
|
@groeneai let’s change the fix. Instead of removing chassert, let us check in the InterpreterExplainQuery.cpp if we are inside a streaming query, and throw some error for the user that would be appropriate. Streaming queries don’t have semantic sense for the Explain analyze anyways. Implement the fix. |
Fgrtue
left a comment
There was a problem hiding this comment.
Get back chassert and apply the change as stated in the #110077 (comment).
EXPLAIN ANALYZE builds a per-step wall-clock registry from the outer query plan. A STREAM read builds a nested QueryPlan at run time (e.g. the streaming MergeTreeCommitOrderSequentialSource) whose steps are absent from that outer plan, so chassert(clock) in ExecutionThreadContext::executeTask fired in debug/sanitizer builds. Timing a streaming read has no semantic meaning (it never completes), so reject such queries with a user error (ILLEGAL_STREAM) in InterpreterExplainQuery instead of relaxing the assertion. Found by the Stress-test AST fuzzer (STID 2508-4031). Co-Authored-By: Claude Opus 4.8 <[email protected]>
60072aa to
a16bb7a
Compare
|
@Fgrtue done. Restored |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-worker-slot-1:20260711-073400 |
| /// A STREAM read builds a nested QueryPlan at run time whose steps are not part of the outer | ||
| /// plan the per-step wall-clock registry is populated from. Timing such a query has no | ||
| /// semantic meaning (a streaming read never completes), so reject it rather than execute it. | ||
| if (dynamic_cast<const MergeTreeCommitOrderSequentialSource *>(proc_ptr)) |
There was a problem hiding this comment.
This blanket ILLEGAL_STREAM check is broader than the bug it fixes. The original failure is a debug/sanitizer-only chassert(clock) when the streaming source injects a runtime sub-pipeline whose processors keep inner-plan step pointers, but this branch now rejects all STREAM queries in release builds too.
That is a real behavior regression for bounded streaming queries that already complete from storage today. tests/queries/0_stateless/04411_streaming_distinct_in_order.sql:29-32 explicitly covers SELECT ... STREAM LIMIT 50, and the reference is 50 / 50, so EXPLAIN ANALYZE is not dealing only with never-ending queries here.
If we want to preserve the chassert(clock) invariant, the fix needs to repair step attribution for the runtime-added processors instead of banning STREAM outright. There is already precedent for this pattern in LazyReadReplacingFinalSource::work, which retags its dynamically built processors with inheritQueryPlanStepFromParent(*this, getQueryPlanStepGroup()) before exposing them to the executor.
|
@Fgrtue the automated review flagged a regression risk in the reject-all approach you asked for, and I want your call before finalizing since it touches the direction of the fix. Findings after checking the code:
Which do you want?
Your call since you own this pivot. I will implement whichever you pick. |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 5/7 (71.43%) · Uncovered code |
CI finish ledger — a16bb7aEvery failure below has an owner (a fixing PR). This PR's diff is
Session id: cron:our-pr-ci-monitor:20260711-130000 |
|
|
||
| /// A STREAM read builds a nested QueryPlan at run time whose steps are not part of the outer | ||
| /// plan the per-step wall-clock registry is populated from. Timing such a query has no | ||
| /// semantic meaning (a streaming read never completes), so reject it rather than execute it. | ||
| if (dynamic_cast<const MergeTreeCommitOrderSequentialSource *>(proc_ptr)) |
There was a problem hiding this comment.
There was a problem hiding this comment.
I think a rare person knows a proper fix better than you @Michicosun. It makes sense to do this fix in #110164 since it reintroduces the feature
This reverts the `EXPLAIN ANALYZE` feature added in ClickHouse#106586 (merge commit 918a0d3), a revert of that merge with `-m 1`. It removes the query-executor instrumentation (`StepWallClock`, `StepWallClockRegistry`, `AnalyzePlanStats`, per-step wall-clock and per-port data accounting on `IProcessor`, per-stage processor grouping on `SortingStep`/`AggregatingStep`/`JoinStep`), the `ANALYZE` keyword and its handling in `ParserExplainQuery`/`InterpreterExplainQuery`, `StreamLocalLimits::forQueryResult`, and the associated tests and documentation. There are no merged follow-up pull requests to revert. The only follow-up, ClickHouse#110077 ("Reject EXPLAIN ANALYZE for streaming (STREAM) queries"), is still open and not part of `master`. The single revert conflict, in `tests/queries/0_stateless/03269_explain_unique_ids.reference`, was resolved to keep the unrelated node-id renumbering introduced later by "Fix Not-ready Set exception by making in-place set build non-destructive" (5583c9a) while reverting only the `EXPLAIN ANALYZE` step-id change. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Closed in favor of #110164 that reintroduces the feature with a fix |
Pull request was closed
This reverts the `EXPLAIN ANALYZE` feature added in ClickHouse#106586 (merge commit 918a0d3), a revert of that merge with `-m 1`. It removes the query-executor instrumentation (`StepWallClock`, `StepWallClockRegistry`, `AnalyzePlanStats`, per-step wall-clock and per-port data accounting on `IProcessor`, per-stage processor grouping on `SortingStep`/`AggregatingStep`/`JoinStep`), the `ANALYZE` keyword and its handling in `ParserExplainQuery`/`InterpreterExplainQuery`, `StreamLocalLimits::forQueryResult`, and the associated tests and documentation. There are no merged follow-up pull requests to revert. The only follow-up, ClickHouse#110077 ("Reject EXPLAIN ANALYZE for streaming (STREAM) queries"), is still open and not part of `master`. The single revert conflict, in `tests/queries/0_stateless/03269_explain_unique_ids.reference`, was resolved to keep the unrelated node-id renumbering introduced later by "Fix Not-ready Set exception by making in-place set build non-destructive" (5583c9a) while reverting only the `EXPLAIN ANALYZE` step-id change. Co-Authored-By: Claude Fable 5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
EXPLAIN ANALYZEnow returns anILLEGAL_STREAMerror for queries reading a table with theSTREAMmodifier, instead of aborting the server in debug/sanitizer builds. Timing a streaming read has no meaning, since it never completes.Description
EXPLAIN ANALYZE(added in #106586) builds a per-step wall-clock registry withStepWallClockRegistry::populateFromPlan(plan), walking the outer query plan and registering a clock for every(step, group). At execution,ExecutionThreadContext::executeTask()looks up the clock for each processor's query-plan step and asserts it exists withchassert(clock).A streaming read (
... FROM t STREAM) is served byMergeTreeCommitOrderSequentialSource, which builds a nestedQueryPlanat run time. Its processors carry step pointers that live only in that inner plan, whichpopulateFromPlannever walks, so those inner steps have no registered clock andchassert(clock)fired in debug/sanitizer builds.EXPLAIN ANALYZEexecutes the query and reports per-step timings, but a streaming read never completes, so timing it has no semantic meaning. Following @Fgrtue's review, this rejects such queries with a user-facingILLEGAL_STREAMerror inInterpreterExplainQuery(in the same pipeline-inspection loop that already rejects distributed execution, so it also catches streaming reads reached through nested sub-plans) and keeps thechassert(clock)invariant intact.Found by the Stress-test AST fuzzer (STID 2508-4031) across
Stress test (amd_tsan),arm_tsan,amd_msan; 0 master hits (release builds caught the exception; only debug/sanitizer builds aborted). Example CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=110006&sha=39b6ace5ea65b69a9e6ee774a0d7b69e882a78a7&name_0=PR&name_1=Stress%20test%20%28amd_tsan%29Reproducer (now returns an error instead of aborting):