Skip to content

Docs: break does not always return a partial result - #113902

Merged
alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
groeneai:docs-timeout-overflow-mode-break-caveat
Aug 13, 2026
Merged

alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
groeneai:docs-timeout-overflow-mode-break-caveat

Conversation

@groeneai

@groeneai groeneai commented Aug 7, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Documentation (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

Description

Both timeout_overflow_mode descriptions promise unconditionally that break returns
"the partial result, as if the source data ran out", so a user picking break to avoid
errors can still get one.

QueryStatus::checkTimeLimit returns false rather than throwing under break, meaning
"stop and return what you have". That works where a truncated output is a
smaller valid one, not where it would be a wrong one, so several sites stop instead of
truncating. A function computing one scalar value (arrayFold, geohashesInBox, string
replace) stops without producing it, surfacing TIMEOUT_EXCEEDED only when not
interrupted mid-pipeline, since a pipeline absorbs the throw into a clean cancellation. An
incomplete Memory-table mutation (StorageMemory::mutate) leaves the table unchanged
and reports it. A quorum write cannot report partial success at all, so it ignores the false
return and does not stop at max_execution_time: it waits out insert_quorum_timeout,
then reports UNKNOWN_STATUS_OF_INSERT. The mutation and dictionary-load waits are the
same, hence "some operations".

The INSERT code differs by executor: QUERY_WAS_CANCELLED when the caller pushes data
block by block, as over the native protocol; "may", because an in-pipeline throw
pre-empts that translation, and a pipeline completed with its own input source raises
nothing. Retention is an engine property, so none is promised.

That sentence also made max_estimated_execution_time a subject of break, but
ExecutionSpeedLimits.cpp:82 gates that check on throw, so the estimate is never
evaluated. That gate predates this change, so only the text is corrected. The leaf
setting has no estimate and reaches no INSERT or quorum write, so those clauses are
omitted there.

The sentence is shared boilerplate appearing 6 times in Settings.cpp; only these 2 are
on the elapsed-time path, so the other 4 threshold modes are unchanged. Hedging is
required in both directions: FillingTransform and sleep do return partial output. No
behaviour changes.

Raised by clickhouse-gh[bot] in #112483 (comment).

Version info

  • Merged into: 26.8.1.1300 (included in 26.8 and later)

The `timeout_overflow_mode` and `timeout_overflow_mode_leaf` descriptions promise
unconditionally that `break` will "stop executing the query and return the
partial result, as if the source data ran out". A user who picks `break`
specifically to avoid errors can still get an error.

`QueryStatus::checkTimeLimit()` returns false rather than throwing under
`break`, signalling "stop and return what you have". That contract is
expressible wherever a truncated output is a smaller valid output, but not
where it would be a wrong one, so several call sites deliberately stop instead
of truncating. Three distinct shapes do this. A function computing one scalar
value (`arrayFold.cpp`, `geohashesInBox.cpp`, `FunctionBaseXXConversion.h`,
`FunctionVariantAdaptor.cpp`, and the string replace family through the shared
`CancellationBudget.cpp` helper, each site carrying an in-code comment stating
the rationale). For that shape the stop reaches the client as
`TIMEOUT_EXCEEDED` only when the call is not interrupted mid-pipeline: a
constant-folded call is evaluated during analysis with no pipeline to absorb the
throw, so the error surfaces, whereas inside a pipeline the executor's own soft
check and the function's check race and either stop is correct, leaving the
query to end without a client-visible error.
`04650_replace_cancellation.sh:203-206` states that race, and its `:218-224`
arm asserts the surfaced error for the folded call. This is why the description
says such a function stops without producing its value rather than naming one
error code for the shape. An operation whose output
must be applied atomically, which among the mutation targets is the `Memory`
table (`StorageMemory::mutate`, which throws "Timeout exceeded while mutating
`Memory` table"; a `MergeTree` mutation instead keeps waiting, see below). And a quorum write, which cannot
report a partial success at all: `ReplicatedMergeTreeSink.cpp:1308-1322`
deliberately ignores the false return and keeps waiting until the quorum is
satisfied or `insert_quorum_timeout` elapses, then reports
`UNKNOWN_STATUS_OF_INSERT`. That shape does not stop the query at
`max_execution_time` at all once the wait has been entered, and
`04337_quorum_insert_honors_time_limit` asserts the quorum outcome. It is not
alone in discarding the false return: the dictionary-load wait
(`ExternalDictionariesLoader.cpp:125`) and the synchronous mutation waits
(`StorageMergeTree.cpp:1074`, `StorageReplicatedMergeTree.cpp:839`) do the same,
which is why the description says "some operations" rather than naming a single
shape. The quorum wait is the one of those with a bound of its own
(`insert_quorum_timeout`, `ReplicatedMergeTreeSink.cpp:1299`), so it is the one
the description names. None of the PRs that introduced those sites amended the
description, which is why it is stale.

The error code depends on which executor runs the query, so the description
names the codes rather than attributing one code to a statement type, and it
hedges: the exception is a property of the site, not of a category. The read
path raises `TIMEOUT_EXCEEDED`. An `INSERT` whose data the caller pushes block
by block runs on `PushingPipelineExecutor` or `PushingAsyncPipelineExecutor`,
which translate the executor's `CancelledByTimeout` status into
`QUERY_WAS_CANCELLED` through `throwOnExecutionStatus`, a helper that exists
nowhere else in `src/`. The common case is the native protocol, which
`03221_insert_timeout_overflow_mode` asserts for both executors
(`TCPHandler.cpp:1501` and `:1506`); the same push loop is also driven by the
PostgreSQL wire `COPY ... FROM` handler (`PostgreSQLHandler.cpp:617`), the gRPC
handler (`GRPCServer.cpp:1069`) and `clickhouse-local`
(`LocalConnection.cpp:388` and `:394`), and the timeout is live on all of them
because `executeQuery.cpp:2055-2058` sets the process list element on any
pushing pipeline. An `INSERT` whose pipeline is instead completed with its own
input source runs on `CompletedPipelineExecutor`, which never inspects the
execution status and so reports no error at all. That covers
`INSERT ... SELECT`, whose reference in
`04416_storage_alias_insert_cancel_no_crash` is a bare `survived` with the
insert's own output piped through a filter that would have shown any error
text, and it also covers an insert whose data is the body of an HTTP request,
which `executeQuery` completes at `:2722-2725` before running it at `:2790`.
Measured against a local server: the same 3000000-row body sent over HTTP under
`break` returned no error, while sending it with `throw` returned
`TIMEOUT_EXCEEDED` and sending it over the native protocol under `break`
returned `QUERY_WAS_CANCELLED`. Calling that shape "streamed" would therefore
point the reader at the wrong code, since an HTTP upload is also a streaming
insert, so the wording names the protocol as the common case without claiming
it is the only one.

The `QUERY_WAS_CANCELLED` wording stays hedged for a second reason: an
in-pipeline throw pre-empts that translation. `PushingPipelineExecutor::push`
reaches `throwOnExecutionStatus` only when `executeStep()` returns false, and
`PipelineExecutor::executeStep` rethrows any `node.exception` at
`PipelineExecutor.cpp:258-260` before reaching `return false` at `:264`; the
async path rethrows at `PushingAsyncPipelineExecutor.cpp:189` before `:192`. A
materialized view's inner `SELECT` runs as an `ExceptionKeepingTransform`
(`InsertDependenciesBuilder.cpp:571`), so a native-protocol `INSERT` feeding a
view whose `SELECT` contains one of the scalar-value functions above reports
`TIMEOUT_EXCEEDED` rather than `QUERY_WAS_CANCELLED`.

Whether any rows survive is a property of the target engine rather than of the
timeout, so the description does not promise retention. `MergeTreeSink::consume`
calls `finishDelayedChunk()` unconditionally once per pushed block; inside it
`checkTimeLimit()` has its bool return discarded, and under `break` that returns
false without throwing, so each pushed block's part is committed during
`consume` and stays: five runs of a 3000000-row native-protocol insert into a
MergeTree table with `max_execution_time = 0.3` reported
`QUERY_WAS_CANCELLED` and left between 1472000 and 1496000 rows in four to seven
committed parts. Engines that publish in `onFinish` keep nothing, because
cancellation stops the executor scheduling further work: `PipelineExecutor::cancel`
calls `finish()`, every executor loop is guarded by `!tasks.isFinished()`, and a
sink's `onFinish()` is reachable only from `work()`. The same insert into
`Memory`, `Log` and `StripeLog` tables reported `QUERY_WAS_CANCELLED` and left
zero rows, the two `Log` engines having truncated their data files back to the
recorded sizes in the sink destructor's rollback branch; rows written before the
statement were unaffected. `StorageMemory::mutate` likewise throws before
swapping its data in, and `04229_memory_mutation_timeout_break` asserts the
table is unchanged afterwards, so the atomic-mutation and scalar-function shapes
are genuine instead-cases and keep that word.

The same sentence also made `max_estimated_execution_time` a subject of `break`,
but `ExecutionSpeedLimits.cpp:82` gates the whole estimated-time check on
`throw`, so under `break` the estimate is never evaluated. That gate is
intentional and predates this change, so only the text is corrected. The leaf
description names `max_execution_time_leaf` and no estimate, and there is no
`max_estimated_execution_time_leaf` setting, so the clause is not repeated
there. For the same reason the leaf description names only `TIMEOUT_EXCEEDED`:
`timeout_overflow_mode_leaf` is read at one site, whose callers are both read
paths, so neither an `INSERT` nor a quorum write is reachable through it.

The hedge is also required in the other direction: `FillingTransform` and
`sleep` honour `break` and do return partial output. Measured with
`max_execution_time = 1, timeout_overflow_mode = 'break'`: a scalar `arrayFold`
over `range(1000000)` gives `elapsed time limit reached in function arrayFold`;
the same fold over 40 ascending rows at `max_block_size = 1` returns rows with
no error; the same scalar fold with `throw` gives the executor's own message
instead of the in-function one; and a `Memory`-table `UPDATE` gives the mutation
message with zero in-function messages, confirming it as a second independent
carrier.

The sentence is shared boilerplate appearing 6 times in `Settings.cpp`; only
these 2 settings are on the elapsed-time path, so the other 4 (row and byte
threshold modes, where a partial result always exists) are left unchanged.
`docs/reference/settings/session-settings/timeout-overflow-mode.mdx` is inside
an AUTOGENERATED region and regenerates from these descriptions, whereas
`query-complexity.mdx` is hand-written and carries the same sentence under its
generic `overflow_mode` heading, so it is updated directly. That heading governs
every `overflow_mode` setting on the page, while this caveat is elapsed-time
only, so the paragraph there names `max_execution_time` explicitly.

No behaviour change. Returning a half-produced value would be silent wrong
results, strictly worse than an exception, so the implementation is correct and
untouched.
@groeneai

groeneai commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 7 review rounds, 6 fix rounds,
9 gate runs). The internal fix-round budget was exhausted before the last two findings below could
be applied to the two documentation surfaces, so this PR is published with them stated rather than
fixed. Both are narrowing corrections to sentences this PR adds; neither reintroduces the promise
the PR removes.

# Sev Finding Verdict Evidence / action
1 ⚠️ The PR description said a scalar-value function turns the break-mode false return into a hard stop, which is the same unconditional framing this PR exists to remove AGREE, fixed @ a348c4a 04408_array_fold_cancellation.reference lines 2 and 4, 04648_geohashes_in_box_cancellation.reference line 3 and 04650_replace_cancellation.reference line 17 all pin a stop with no client-visible error; 04650_replace_cancellation.sh:203-206 states the race and :218-224 scopes the surfaced error to a constant-folded call. Description rewritten to match the shipped wording
2 ⚠️ "A mutation of a Memory table leaves the table unchanged and reports TIMEOUT_EXCEEDED" is categorical, but the partial-column branch only rejects an INCOMPLETE result AGREE, not fixed StorageMemory.cpp:334-341 (all-columns) throws on any cancellation, so the claim holds there. The partial-column branch at :347-372 consults the cancellation flag only when the block count or a per-block row count disagrees; if the deadline flips after every expected block was produced, :374-400 commits the mutation. PullingPipelineExecutor::pull(Block) at :67-79 returns true with an empty block on the soft timeout, so a late flip is reachable. The remedy is one word: say an incomplete mutation
3 ⚠️ The quorum sentence attaches "then reports UNKNOWN_STATUS_OF_INSERT" to both quorum satisfaction and timeout, but a satisfied quorum succeeds AGREE, fixed in the description, not in the two documentation surfaces ReplicatedMergeTreeSink.cpp:1341 logs "satisfied" and returns; the throw at :1318-1322 is guarded by if (!quorum_updated), i.e. timeout only. The remedy is "if insert_quorum_timeout elapses before the quorum is satisfied, it reports ..."

Severity: ❌ blocker / ⚠️ major / 💡 nit. Findings 2 and 3 are the residual: I would rather state
them here than leave them undisclosed, and I am happy to push both one-sentence corrections on
request.

Verified clean and left byte-identical: the throw-only gating of the estimated-time check
(ExecutionSpeedLimits.cpp:82); the INSERT / QUERY_WAS_CANCELLED hedge (throwOnExecutionStatus
exists at exactly two sites in src/, and CompletedPipelineExecutor never inspects the execution
status); the "some operations" hedge (four distinct sites discard the false return, with
StorageReplicatedMergeTree.cpp:7741 as the control that does test it); the hedging in the other
direction (FillingTransform and sleep do return partial output); the leaf scoping
(timeout_overflow_mode_leaf has one read site whose callers are both read paths, and no
max_estimated_execution_time_leaf setting exists); and the surface selection
(query-complexity.mdx carries no autogenerated region, whereas
timeout-overflow-mode.mdx is wholly generated from these descriptions and is left to the
nightly generator).

Session id: cron:clickhouse-review-slot-9:20260807-232300

@groeneai

groeneai commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, four arms on the same Build-ID-verified debug binary at max_execution_time = 1. Witness: SELECT length(arrayFold((acc, x) -> concat(acc, toString(x)), range(3000000), '')) SETTINGS timeout_overflow_mode = 'break' gives Code: 159 ... elapsed time limit reached in function arrayFold. Second witness (a non-function carrier): an ALTER TABLE ... UPDATE on a 3M-row Memory table under break gives Timeout exceeded while mutating \Memory` table`, with zero in-function messages.
b Root cause explained? QueryStatus::checkTimeLimit returns false rather than throwing under break, meaning "stop and return what you have". That is expressible where a truncated output is a smaller valid output, but not where it would be a wrong one, so some call sites stop instead of truncating. The two timeout_overflow_mode descriptions promise the partial result unconditionally and never mention that. For the scalar-function shape the stop reaches the client as TIMEOUT_EXCEEDED only when the call is not interrupted mid-pipeline: a constant-folded call is evaluated during analysis with no pipeline to absorb the throw, so the error surfaces, whereas inside a pipeline the executor soft check and the function check race and either stop is correct, so the query ends with no client-visible error. 04650_replace_cancellation.sh lines 203-206 state that race and lines 218-224 assert the surfaced error for the folded call, while 04408_array_fold_cancellation.reference lines 2 and 4 and 04648_geohashes_in_box_cancellation.reference line 3 pin the absorbed outcome. This is why the description says such a function stops without producing its value rather than naming one code for the shape. The error code differs by pipeline, so the description names the codes hedged rather than attributing one code to a statement type: the read path raises TIMEOUT_EXCEEDED; an INSERT may report QUERY_WAS_CANCELLED when its caller pushes the data block by block, as over the native protocol, whereas an INSERT whose pipeline is completed with its own input source, including INSERT ... SELECT and an HTTP body insert, runs on CompletedPipelineExecutor, which never inspects the execution status and so reports nothing. That claim has to be hedged rather than categorical for a second reason: an in-pipeline throw pre-empts the translation, because PipelineExecutor::executeStep rethrows any node.exception at PipelineExecutor.cpp lines 258-260 before it can reach return false at line 264 (the async path rethrows at PushingAsyncPipelineExecutor.cpp line 189 before line 192), so a native-protocol INSERT feeding a materialized view whose inner SELECT contains one of these functions reports TIMEOUT_EXCEEDED instead. A third code is reachable as well: a quorum write cannot report a partial success, so ReplicatedMergeTreeSink.cpp lines 1308-1322 deliberately ignore the false return and keep waiting until the quorum is satisfied or insert_quorum_timeout elapses, then report UNKNOWN_STATUS_OF_INSERT; that shape also does not stop the query at max_execution_time once the wait has been entered, and 04337_quorum_insert_honors_time_limit asserts the quorum outcome. It is not alone in discarding the false return: enumerating every site in src/ where the checkTimeLimit() bool is dropped, and separating those from the sites that test it (positive control: StorageReplicatedMergeTree.cpp:7741 does test it), puts the dictionary-load wait (ExternalDictionariesLoader.cpp:125) and the synchronous mutation waits (StorageMergeTree.cpp:1074, StorageReplicatedMergeTree.cpp:839) in the same class, which is why the description says "some operations" rather than naming a single shape. The quorum wait is the one of those with a bound of its own, insert_quorum_timeout at ReplicatedMergeTreeSink.cpp:1299, so it is the one the description names. Whether rows survive is a property of the target engine, so no retention is promised. Separately, the same opening sentence made max_estimated_execution_time a subject of break, but ExecutionSpeedLimits.cpp:82 gates the whole estimated-time check on throw, so under break that limit is never evaluated.
c Fix matches root cause? Yes, and deliberately no code changes. Returning a half-produced scalar or a half-applied mutation would be silent wrong results, so the implementation is correct; the defect is only in the description text, which is what changed. No bound widened, no test tag added, no defensive check inserted.
d Test intent preserved / new tests added? No test file is touched, and none is applicable: a description is not behaviour. 03999_stateless_settings_history never reads description (0 occurrences; its frozen baseline is name, kind and default only), and 01324_settings_documentation plus 02392_every_setting_must_have_documentation require a description to exist and be non-trivial, which a longer one satisfies. All three pass 50 of 50 randomized runs.
e Both directions demonstrated? Yes, with three anti-leak counts, each measured as exactly-N rather than at-least-one. Both timeout_overflow_mode and timeout_overflow_mode_leaf carry the new sentence and still carry the original partial-result promise, while the four out-of-scope carriers of the same boilerplate (result_overflow_mode, set_overflow_mode, transfer_overflow_mode, distinct_overflow_mode) do not: carriers of the caveat are exactly 2, of the estimated-time clause exactly 1, of QUERY_WAS_CANCELLED exactly 1 and of UNKNOWN_STATUS_OF_INSERT exactly 1, while the count still carrying the unqualified promise is 6 before and 6 after, so nothing was weakened. The behavioural side is a witness, a positive control (the same fold over 40 ascending rows at max_block_size = 1 returns rows with no error) and a negative control (the same fold under throw reports the executor message instead).
f Fix is general across code paths? Yes, and the citations below are resolved against current master, not the branch base. Sites that stop instead of truncating under break (the scalar-function ones surface TIMEOUT_EXCEEDED only when not interrupted mid-pipeline, see row b): the shared helper CancellationBudget.cpp line 34 (used by FunctionStringReplace.h, ReplaceStringImpl.h and CountSubstringsImpl.h), plus the inline sites arrayFold.cpp line 332, geohashesInBox.cpp line 217, FunctionBaseXXConversion.h line 369, FunctionVariantAdaptor.cpp line 42, and StorageMemory.cpp line 327. A quorum write is a third such shape, and it neither returns a partial result nor stops at max_execution_time once its wait is entered: ReplicatedMergeTreeSink.cpp lines 1308-1322 ignore the false return by design and end the wait with UNKNOWN_STATUS_OF_INSERT, which 04337_quorum_insert_honors_time_limit asserts and which this PR leaves untouched. It is not the only wait in that class: the dictionary-load wait at ExternalDictionariesLoader.cpp line 125 and the synchronous mutation waits at StorageMergeTree.cpp line 1074 (waitForMutation, reached from mutations_sync > 0 at line 1126) and StorageReplicatedMergeTree.cpp line 839 (waitMutationToFinishOnReplicas) discard the same false return, and unlike the quorum wait they carry no timeout of their own, so under break a synchronous MergeTree mutation keeps waiting rather than reporting TIMEOUT_EXCEEDED. The same file's lines 1047 and 1294 discard it too, but those are the table-creation and replica-creation retry loops rather than mutation waits, so they are not cited as such. That is why the description qualifies the mutation example as a Memory-table mutation, whose StorageMemory.cpp line 327 does throw, and why it says "some operations" for the waiting class instead of naming the quorum write alone. Two sites translate the status into QUERY_WAS_CANCELLED: PushingPipelineExecutor.cpp lines 84-89 and PushingAsyncPipelineExecutor.cpp lines 173-178, each mapping CancelledByTimeout to that code through throwOnExecutionStatus, which exists nowhere else in src/, and which 03221_insert_timeout_overflow_mode asserts for both. Both are reached from any caller that pushes an insert's data block by block, which executeQuery.cpp lines 2055-2058 arm by setting the process-list element on every pushing pipeline, so the user-facing entry points are not limited to one protocol: TCPHandler.cpp lines 1501 and 1506 for the native protocol, and also PostgreSQLHandler.cpp line 617 for a wire-protocol COPY ... FROM, GRPCServer.cpp line 1069, and LocalConnection.cpp lines 388 and 394 for clickhouse-local. The description names the native protocol because it is the common case and the one 03221 asserts, and because naming a protocol rather than calling the shape "streamed" is what distinguishes it from an HTTP body insert, which is also a streaming insert yet has executeQuery complete its pipeline so it runs on CompletedPipelineExecutor, whose file contains zero occurrences of getExecutionStatus, ExecutionStatus or either error code against 2 and 1 in the pushing executors, and src/Server/HTTPHandler.cpp contains no Executor reference at all. Measured against a local server: the same 3000000-row body under break returned no error over HTTP but QUERY_WAS_CANCELLED over the native protocol, and returned TIMEOUT_EXCEEDED over HTTP with throw. INSERT ... SELECT behaves like HTTP and 04416_storage_alias_insert_cancel_no_crash asserts it with a bare survived reference. Three honour break and do return partial output: FillingTransform.cpp line 421, sleep.cpp line 168, PipelineExecutor.cpp line 289. All three groups are load-bearing: the first group is why the caveat is needed, the two pushing sites are why naming a single code would repeat the same incomplete promise in miniature, and the last three are why the text says "some operations" rather than an absolute. The description names no individual function or storage, which is deliberate: the set has already grown and been refactored behind a shared helper since this task was filed. The leaf description names only TIMEOUT_EXCEEDED: timeout_overflow_mode_leaf has one read site in src/, whose callers are both read paths, and DistributedSink.cpp names neither leaf setting while grep -c "Setting::" on it returns 28 lines, so that zero is a real absence rather than a broken probe and naming the INSERT code there would be a new false claim.
g Fix generalizes across inputs (params/datatypes/wrappers)? The input matrix here is the set of settings carrying the sentence. It appears 6 times in src/Core/Settings.cpp; the 2 on the elapsed-time path are changed and the other 4 are row and byte threshold modes that trip on a counted limit between rows and blocks, so a partial result always exists and their promise holds unconditionally. Changing them would state something false about them. Both in-scope settings reach the same QueryStatus::checkTimeLimit, which is why both hunks are present rather than one. A single-line grep for the sentence returns zero because it is line-wrapped in the raw string.
h Backward compatible? (maintainer-approved exception only) Yes. No default, name, type or tier change and no format change. No SettingsChangesHistory.cpp entry is required, established by running check_settings_changes_history rather than by inspection: it returns empty for this file list, and returns non-empty once src/Core/SettingsChangesHistory.cpp is added to that list, so the skip is real.
i Invariants and contracts preserved? Yes, trivially: no behaviour and no code. The DECLARE invocations and their argument lists are unchanged apart from raw-string content; the tree builds and links and the server starts and answers. The documented contract becomes strictly more accurate, since the partial-result promise survives verbatim for the shapes that honour it and the previously undocumented exception is now stated.

Session id: cron:clickhouse-impl-slot-41:20260807-230800

@groeneai

groeneai commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

cc @vitlibar, could you review this? It is text only: the timeout_overflow_mode descriptions promise that break always returns a partial result, but several sites cannot express one and stop instead, and a quorum write does not stop at max_execution_time at all.

@Blargian Blargian added the pr-documentation Documentation PRs for the specific code PR label Aug 10, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [bc210c5]

Summary: ✅


AI Review

Summary

This PR narrows the timeout_overflow_mode documentation to explain that break does not always yield a partial result and that max_estimated_execution_time is only checked in throw mode. The new wording in src/Core/Settings.cpp and docs/concepts/features/configuration/settings/query-complexity.mdx matches the traced runtime paths, but the fix is still incomplete because the checked-in reference page for /reference/settings/session-settings/timeout-overflow-mode remains stale.

Findings

⚠️ Majors

  • [src/Core/Settings.cpp:3303] [dismissed by author -- https://github.com/Docs: break does not always return a partial result #113902#discussion_r3765907285] The PR updates the source docstring but not the committed generated page docs/reference/settings/session-settings/timeout-overflow-mode.mdx, which still says break always returns a partial result and still documents the estimated-time path without the new throw-only caveat (timeout-overflow-mode.mdx:19-36). I still consider this real because that checked-in page is the English reference surface for /reference/settings/session-settings/timeout-overflow-mode, so merging this PR leaves the main docs contradictory until a separate docs-autogen sync happens.
    Suggested fix: regenerate the session-settings reference docs and ship the updated docs/reference/settings/session-settings/timeout-overflow-mode.mdx in the same change.
Final Verdict

Changes requested.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.70% 86.70% +0.00%
Functions 92.00% 92.00% +0.00%
Branches 79.00% 79.10% +0.10%

Changed lines: Changed C/C++ lines covered: 29/29 (100.00%) · Uncovered code

Full report · Diff report

@Blargian Blargian added the can be tested Allows running workflows for external contributors label Aug 12, 2026
Comment thread src/Core/Settings.cpp Resolved
Comment thread src/Core/Settings.cpp Resolved
Two sentences added by the previous commit are themselves categorical where the
source is conditional, which is the defect class this change exists to remove.

`StorageMemory::mutate` has two branches and only one throws unconditionally.
The all-columns branch fails closed on any cancellation. The partial-column
branch throws only from `reject_incomplete`, which fires on a block-count or a
per-block row-count mismatch, so a soft timeout that flips after every expected
block was already produced passes both shape checks and the mutation is
committed with no exception. That late flip is reachable rather than theoretical:
`PullingPipelineExecutor::pull(Block)` returns true with a cleared block on the
soft timeout, which is the case the second shape check exists to catch. The text
now scopes the unchanged-table-plus-`TIMEOUT_EXCEEDED` outcome to a mutation the
timeout leaves incomplete.

`ReplicatedMergeTreeSink::waitForQuorum` throws `UNKNOWN_STATUS_OF_INSERT` under
`if (!quorum_updated)`, reached only when the inner wait exits on
`quorum_timeout_ms`, which is `insert_quorum_timeout`. If the quorum is satisfied
first the watch fires, the loop breaks with `quorum_updated` set and the wait
returns normally after logging that the quorum is satisfied. The previous wording
attached the report to both alternatives; it now attaches it to the timeout
branch alone, leaving the ignored false return and the absent
`max_execution_time` stop unchanged, since both of those are correct.

The leaf description is deliberately untouched: it names neither shape, because
`timeout_overflow_mode_leaf` is read at a single site whose callers are both read
paths, so no `INSERT` and no quorum write is reachable through it.

No behaviour change; both files carry the same sentence and both are updated.
The `timeout_overflow_mode` row of the hand-written summary table in
`query-complexity.mdx` is a verbatim copy of the first sentence of the
setting's `DECLARE` docstring in `src/Core/Settings.cpp`. This PR added
"(the estimate is only checked with `throw`)" to that docstring and left
the copy behind, so the two surfaces of the same sentence disagreed and
the page still documented a `break`-mode estimated-time path.

`ExecutionSpeedLimits.cpp:82` gates the whole estimated-time block on
`timeout_overflow_mode == OverflowMode::THROW`, so under `break` the
estimate is never evaluated. The gate predates this change; only the
text is corrected.

Measured: the row is byte-identical at the PR base and at `origin/master`
and was an exact mirror of the docstring sentence at both, so the
divergence was introduced by this PR rather than pre-existing. The
autogenerated `timeout-overflow-mode.mdx` page carries the same sentence
but regenerates from `Settings.cpp` and is correctly left untouched.
`timeout_overflow_mode_leaf` has no estimate setting, so its row is
unchanged.

Raised by clickhouse-gh[bot] in
ClickHouse#113902 (comment)
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - bc210c5

CI is fully finished and green: 176 check-runs, 0 incomplete, 0 red (153 success / 23 skipped),
Config Workflow and Finish Workflow both success. The praktika report is top-level OK with
174 leaves and 0 dropped jobs, so the run has real coverage; every skip carries a reason
(docs-only diff).

No failed tests, so no owner rows are needed.

Session id: cron:our-pr-ci-monitor:20260812-170000

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasonable.

@alexey-milovidov alexey-milovidov self-assigned this Aug 13, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 13, 2026
Merged via the queue into ClickHouse:master with commit b73d6cc Aug 13, 2026
180 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 13, 2026
@groeneai groeneai added the groeneai-origin-self PR origin: self-found defect (impact-bar validated) label Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors groeneai-origin-self PR origin: self-found defect (impact-bar validated) pr-documentation Documentation PRs for the specific code PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants