Repository navigation
Conversation
A stress run aborted the server with
Logical error: 'offsets_column has data inconsistent with nested_column.
Data size: 100000, last offset: 44460'
from ExactSetRuntimeFilter::insert, reached through RuntimeFilterLookup::add
<- BuildRuntimeFilterTransform::prepare (STID 2632-398f, first sighting of the
signature in 90 days of CIDB; the carrier PR was test-only).
ISimpleTransform::work does not tear the pipeline down where a transform throws:
it converts the exception into port data and returns, and for an exception
arriving from upstream it calls the transform(std::exception_ptr &) hook and
forwards it. Either way the transform still reaches Finished, and
BuildRuntimeFilterTransform::prepare() called finish() on that status
unconditionally, so a build stream whose build had failed registered its
half-built filter anyway. RuntimeFilterLookup::add then merged it, and the merge
reads the source filter's Set value columns through getValuesColumn() ->
Set::getSetElements(): one of those columns had been left mid-append by the
interrupted insert, so re-running the ColumnArray consistency check on it fired
LOGICAL_ERROR and abortOnFailedAssertion took the whole server down, from a
thread of a different build stream than the one that failed.
The interrupted column is a ColumnArray(ColumnVariant) grown by
Set::appendSetElements. ColumnVariant::insertRangeFromImpl's general path grows
local_discriminators and offsets first (and ColumnVariant::size() is
offsets->size()), then appends the variant payloads, which is what threw under
the job's memory_tracker_fault_probability; ColumnArray::insertRangeFrom writes
its own offsets only after getData()->insertRangeFrom returns, so the data grew
and the offsets did not. That is the trigger, not the defect: IColumn documents
no all-or-nothing contract for insertRangeFrom and ships
getCheckpoint()/rollback() precisely so a caller that must retain a column
across a throwing append can undo it. The defect is publishing a filter whose
build failed.
So abandon the build instead. built_filter == nullptr is the abandoned state -
the constructor assigns it on all three of its paths, so a null pointer cannot
arise otherwise - and three guards carry the invariant "a build stream whose
build failed must never register its filter and never re-enter the build with
it": a catch-all in transform(Chunk &) that releases the filter and rethrows
unchanged (covering both the insert and the CAST that precedes it), a
transform(std::exception_ptr &) override that releases it when the build side
stopped early, and an early return in finish(). The entry guard in
transform(Chunk &) is needed because ISimpleTransform keeps the transform alive
and re-enters it on later chunks; without it the released pointer is
dereferenced, which the same-shaped LimitBySortedStreamTransform regression test
already documents for its own scratch buffer.
Withholding is safe by construction rather than by a new rule: a runtime filter
is an optimization, and FunctionApplyFilter already treats a filter that is
absent from the lookup, or not yet ready, as all-pass. On a multi-stream build
the surviving siblings still register, so the withheld merge leaves
hasPendingMerges() true, isReady() false and the probe passing every row, which
gtest_runtime_filter_lookup already asserts. Releasing the pointer is also what
makes the corrupt column unreachable: the filter is the only owner of the Set.
The new gtest drives the transform the way the executor does, injecting a
deterministic allocation failure with a MemoryTracker hard limit rather than a
failpoint, and forces the registration path by closing a connected downstream
port. Its third arm is an anti-vacuity arm: a build that completes must still
register a filter that actually filters, so a bare return in finish() cannot
satisfy the other two. An Array(String) key selects the exact-set filter variant
from the reported stack. Reverting any one of the three guards reddens a
different arm.
Co-Authored-By: Claude Opus 5 <[email protected]>
Drop the three clauses that narrate the fix; keep the base-class and probe-side properties a reader cannot derive locally.
Internal second-model review: adjudication log (click to expand)An independent-model gate pass over this branch (engine: codex) returned 0 findings; my own cold
Severity: ❌ blocker / Checked independently and found sound: the reported stack reads as an abort on the insert path, which Noticed while reviewing and deliberately not raised as separate work, no user-reachable consequence Session id: cron:clickhouse-review-slot-11:20260918-234200 |
|
Workflow [PR], commit [e1bebf8] Summary: ❌
AI ReviewSummaryThis PR prevents the original Findings
Final Verdict
LLVM Coverage ReportMeasured on commit e1bebf8.
Changed lines: Changed C/C++ lines covered: 119/121 (98.35%) · Uncovered code |
…abandon-failed-build
CI finish ledger - 31fc30dEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
Rule 3c, not 3d, decided at the tree that ran rather than at the head: praktika builds the merge Session id: cron:our-pr-ci-monitor:20260919-053557 |
| if (filter_key.empty()) | ||
| return; | ||
| /// A filter missing from the lookup is all-pass on the probe side. | ||
| if (!built_filter) |
There was a problem hiding this comment.
transform(std::exception_ptr &) only handles the path where work() actually consumes an exception packet. ISimpleTransform::prepare() returns Finished immediately when output.isFinished() is true (src/Processors/ISimpleTransform.cpp:27-32), and BuildRuntimeFilterTransform::prepare() still calls finish() on every Finished status. In the teardown where another build stream fails first, this stream can still have an unprocessed upstream exception queued while its output gets closed; built_filter is still non-null here, so finish() will register an incomplete filter anyway. That means the new upstream-exception fix is still bypassable unless registration distinguishes natural end-of-input from downstream/cancelled finish, or abandons the filter on that path too.
There was a problem hiding this comment.
The early-Finished path is real and finish() does run on it, but it cannot register a filter in the state this PR is about.
built_filter != nullptr at finish() is itself the proof that no insert was interrupted. The only mutation of the filter's contents is built_filter->insert(...) at BuildRuntimeFilterTransform.cpp:126, inside the try whose catch (...) at :128-133 resets built_filter unconditionally and rethrows. So if built_filter survives to the check at :148, every insert that ran on it returned normally, and its exact-value columns are structurally consistent.
That distinction is the defect. The abort is RuntimeFilter::merge -> ExactSetRuntimeFilter::mergeFrom -> Set::insertFromColumns -> convertToFullIfWrapped -> the ColumnArray size check data->size() != offsets.back(). It needs a mid-append column, not a short one: a filter that stopped early holds fewer values than the full build side, but its offsets and its nested data still agree, so the check passes. Incomplete and mid-append are different states. That also makes the queued-exception interleaving moot here: whichever way that race goes, the column that gets registered is consistent.
prepare() is byte-for-byte master's at :97-105 (the hunks start at transform(Chunk &)), and the diff adds no registration site: one entry guard, one catch-all reset, one transform(std::exception_ptr &) reset, one finish() guard. Every registration reachable at this head is reachable on master too, so the change strictly narrows registration. ISimpleTransform::prepare() returns Finished from three places: output.isFinished() (:27-32), no_more_data_needed (:52-57, unreachable here because this transform never calls stopReading()), and input.isFinished() (:62-67). All three reach finish(), and on all three the built_filter != nullptr precondition carries the same guarantee.
So I am not extending the fix to reset on the downstream-closed path: registering a short filter there is master's existing behavior, it is orthogonal to this abort, and withholding it would change filter publication on a path I have no failure for.
Build profile diff (arm_release)Comparing commit See the job log for details. |
CI finish ledger - fbfc27cEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task whose
The two other rows of the previous ledger are green at this head: Session id: cron:our-pr-ci-monitor:20260919-110331 |
|
Looks like a quickhack. |
|
Agreed on the shape: it guards one consumer instead of removing the bad state. The defect is still on master. What I sent only stops Smaller and at the right level: take checkpoints of Want me to open that instead? |
Related: #107108
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed
LOGICAL_ERROR: offsets_column has data inconsistent with nested_columnwhen building a JOIN runtime filter failed part way through, for example on a memory limit. The half-built filter was registered anyway, and a later merge read its partially appended key column, replacing the error the query actually hit (and aborting the server whereLOGICAL_ERRORis fatal: sanitizer builds,abort_on_logical_error). Such a build is now abandoned, and an unregistered runtime filter passes all rows. Runtime filters are on by default (enable_join_runtime_filters).Description
Found in CI (
Stress test (arm_release)); first sighting in 90 days of CIDB, and the carrier PR istest-only, so the failing code is master's. No related issue.
Provenance: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120711&sha=6c62261a7eb5abed01a007c5bf0cd1906b84e573&name_0=PR&name_1=Stress%20test%20%28arm_release%29
What breaks.
ISimpleTransform::workturns an exception thrown bytransforminto port data andkeeps the transform alive, so a build stream whose build failed still reaches
prepare() == Finished,where
BuildRuntimeFilterTransform::finish()registered it unconditionally.RuntimeFilterLookup::addthen merges it, reading a
Setvalue column the interrupted insert had left mid-append, so theColumnArrayconsistency check throws, in a different build stream than the one that failed.Change. Abandon the build instead of publishing it: release
built_filteron any exception fromtransform(Chunk &)(rethrowing it unchanged) and on thetransform(std::exception_ptr &)upstreamhook, and skip registration in
finish()once it is gone. The early return intransform(Chunk &)isneeded because the transform is re-entered on later chunks. No new state:
built_filter == nullptristhe abandoned state, and a filter missing from the lookup is already all-pass on the probe side
(
FunctionApplyFilter).Validation. A new lifecycle gtest fails on master and passes here, reverting each guard on its own
reddens a different arm, and the
*runtime_filter*stateless family, the runtime-filter gtests andtype-coverage tests (50x) pass. A gtest rather than SQL because this is a transform lifecycle property:
with one build stream master need not reach
finish()after the throw, with several the created-filtercounter reads the same either way, and the remaining SQL observable is the abort, which needs an
allocation failure at a precise instant. Such a query always fails rather than completing with a
partial key set, so there is no wrong-results path.
Workflow [PR]
Sync PR [sync-upstream/pr/120940]