Skip to content

Fix DROP TABLE hanging forever after a persisted loop() table has been read - #118947

Open
groeneai wants to merge 5 commits into
ClickHouse:masterfrom
groeneai:fix-drop-source-table-of-persisted-loop-table
Open

groeneai wants to merge 5 commits into
ClickHouse:masterfrom
groeneai:fix-drop-source-table-of-persisted-loop-table

Conversation

@groeneai

@groeneai groeneai commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fixed DROP TABLE t SYNC never returning when t is the source of a persistent table created as CREATE TABLE ... AS loop(t) and that table has been read at least once. Such a table now resolves its source by name on every read instead of holding on to the source's storage object, so the source can be dropped, and reading the persistent table afterwards raises UNKNOWN_TABLE instead of returning rows from the dropped table. Reading it after the source's column types changed now converts the values instead of reinterpreting them under the cached type, which aborted a debug or sanitizer build and was also reachable with ALTER TABLE t MODIFY COLUMN.

Description

Related: #116629 (found while probing its read path). Closes #119765.

CREATE TABLE dl AS loop(t) creates a persistent StorageTableFunctionProxy. The first read of dl materialises the proxy's nested storage, and from then on DROP TABLE t SYNC never returns and must be KILL QUERYed. t leaves system.tables but stays in system.dropped_tables until restart, so its data is not reclaimed.

Root cause: StorageLoop stored the source as a StoragePtr member, and the persisted proxy memoises that StorageLoop for the server's lifetime (StorageTableFunctionProxy::getNestedImpl). The background drop task only takes a table whose pointer is unique (DatabaseCatalog::getTablesToDrop), so waitTableFinallyDropped waits forever.

Fix: StorageLoop keeps a StorageID and resolves it per read, the settled convention for a storage referencing another table (StorageBuffer, StorageMaterializedView, StorageAlias); the query plan pins the resolved table for its own query. The LoopSource branch that read the retained storage, the source of the stale rows, is deleted. The id is the name the user wrote, so the source resolves as it does for SELECT ... FROM db.tbl, covering table-function-backed databases (Filesystem, S3, HDFS) whose storages are not registered under their own id; 02722_database_filesystem gains an arm.

Resolving live leaves the source's schema mutable behind the header cached at CREATE, so the read now converts to it; that also fixes a Bad cast logical error pre-existing on master via ALTER TABLE t MODIFY COLUMN.

Validation: 05137_loop_table_function_drop_source_table fails on pristine master (Code: 159, 31 s) and passes with the fix; the 50/50 and the loop family are green, and persisted loop() tables still attach.

Not fixed here: mergeTreeIndex and four mergeTree* siblings pin their parent the same way, but read its parts through that handle, so the remedy differs.


Workflow [PR]
Sync PR [sync-upstream/pr/118947]

groeneai and others added 3 commits September 8, 2026 21:42
…n read

CREATE TABLE dl AS loop(t) creates a persistent StorageTableFunctionProxy. The
first read of dl materialises the proxy's nested storage, and from then on
DROP TABLE t SYNC never returns and has to be KILL QUERYed. t leaves
system.tables but stays in system.dropped_tables until the server restarts, so its
data is not reclaimed before then, and SELECT * FROM dl keeps returning the dropped
table's rows.

TableFunctionLoop::executeImpl resolves the named source and hands the
StoragePtr to StorageLoop, which stored it as a data member. For a persisted
table StorageTableFunctionProxy::getNestedImpl memoises that StorageLoop and
clears get_nested, so the strong reference to the source's storage object lives
for the whole server lifetime. DatabaseCatalog's background drop task only takes
an entry whose pointer is unique (!isSharedPtrUnique(it->table)), so in_use stays
true and the UUID never leaves tables_marked_dropped_ids, so
waitTableFinallyDropped keeps waiting: it returns only on shutdown, or throws out of
its throw_if_cancelled callback (QUERY_WAS_CANCELLED on a KILL, TIMEOUT_EXCEEDED under
max_execution_time).

StorageLoop now keeps a StorageID and resolves it per read, the settled
convention for a storage that references another table: StorageBuffer holds
destination_id, StorageMaterializedView holds target_table_id, StorageAlias
holds target_database and target_table. The UUID is cleared so the source is
followed by name, which is also what lets dl pick up a source that was dropped
and recreated. ReadFromLoopStep and LoopSource still take the resolved
StoragePtr and pin it for the duration of their own query, exactly as
ReadFromMerge::selected_tables does; only retention on the storage is removed.

LoopSource::initLoop now tests inner_table_function_ast first. That is required
rather than cosmetic: master's first branch dereferenced inner_storage, which is
null for the inner-table-function form. The two forms
are mutually exclusive by construction, since executeImpl sets the AST exactly
for the inner-table-function form and leaves it null for the named form.

The branch that read inner_storage directly is deleted. It is where the stale rows
came from: it served a named source that had already been dropped.
processed_stage, max_block_size and num_streams go with it, since that branch was
their only consumer and on both surviving paths the inner SELECT is built by the
interpreter, which derives those from its own context.

The metadata snapshot is deliberately still taken in the constructor with
CurrentThread::tryGetQueryContext(). InterpreterCreateQuery calls executeImpl
with use_global_context = true, so resolving it from executeImpl's context
instead would silently change which context reads the schema.

The mergeTree* introspection table functions retain their parent the same way
and still pin it, but they read its parts through that handle, so they need a
different remedy than per-read resolution and are left alone here.

Co-Authored-By: Claude Opus 5 <[email protected]>
…ertises

Resolving the source per read makes its schema mutable behind an already-created
loop table, and LoopSource still advertised the header cached at CREATE:
storage_snapshot->getSampleBlockForColumns() in the ISource constructor and in
ReadFromLoopStep. A source whose column type had changed therefore sent its
columns unconverted under the cached header. A port compares only the column
count (InputPort::pullData and OutputPort::pushData test
chunk.getNumColumns() != header->columns() and nothing else), and
StorageTableFunctionProxy::read's own "Converting columns" step is an identity
here because query_plan.getCurrentHeader() is already the cached header by the
time it runs. The mismatched column travelled to the wire, where
SerializationNumber typeid_casts it and abortOnFailedAssertion fires:

  Logical error: 'Bad cast from type DB::ColumnString to DB::ColumnVector<char8_t>'
  Received signal Aborted (6)

Measured on a debug server, both directions. Reaching it by dropping and
recreating the source with a different type is new to this change: on
bd4f088 that sequence returns the pre-drop rows instead, because the
source's storage object is still pinned. Reaching it by ALTER TABLE ... MODIFY
COLUMN on a non-key column is not new - it aborts identically on
bd4f088 - and the same conversion step fixes that route too. A key
column cannot be retyped at all (ALTER of key column ... is not safe), so the
non-key form is the only ALTER route.

LoopSource::initLoop now appends an ExpressionStep built by
ActionsDAG::makeConvertingActions when the built plan's header is not
structurally equal to the header this source advertises, which is the same shape
StorageTableFunction.h:193-210 uses and which
04653_table_function_proxy_prewhere_type_drift pins for the sibling case. It is
placed after the plan is built, so it covers the named-source form and the
inner-table-function form (loop(file(...)) rebuilds from the current external
schema and can drift the same way). A conversion that is not possible throws out
of makeConvertingActions, which is the wanted outcome: CANNOT_PARSE_TEXT rather
than an abort.

05137 gains one drift arm, recreating the source as String holding '3' and
asserting the read returns 3. The test also now pins
ignore_drop_queries_probability = 0, because the stress runner passes 0.2 to
every client (ci/jobs/scripts/stress/stress.py) and InterpreterDropQuery turns a
DROP of a table with data on disk into a silent no-op when it fires, which would
make the UNKNOWN_TABLE arm return a row about one Stress run in five. And it
asserts system.dropped_tables no longer holds the source once the SYNC drop
returns, an oracle for the retained reference that does not depend on the
statement's timeout.

Co-Authored-By: Claude Opus 5 <[email protected]>
SELECT * FROM loop(<database>, '<table>') over a table-function-backed database
threw Code: 81 UNKNOWN_DATABASE. That is a regression of the first commit on this
branch: a plain query, no persisted table and no drop anywhere.

StorageLoop derived the id it resolves per read from the resolved StoragePtr, and
for a table-function-backed database that object's id is not the name the user
wrote. DatabaseFilesystem::getTableImpl, DatabaseS3::getTableImpl and
DatabaseHDFS::getTableImpl each return the storage their table function built,
unrenamed, so its id carries ITableFunction::getDatabaseName()'s synthetic
_table_function database. That is not a database in DatabaseCatalog, so resolving
the id threw. DatabaseURL is not affected: DatabaseURL::getTableImpl wraps its
delegate in a StorageURLDatabaseTable carrying StorageID(getDatabaseName(), name).

The deleted direct-read branch had served this population as well. Its gate was
DatabaseCatalog::isTableExist, which returns false for an unknown database instead
of throwing, so _table_function.<file> fell through to it and read fine.

TableFunctionLoop::executeImpl now hands StorageLoop the logical StorageID it
already computes for the named form, and ReadFromLoopStep and LoopSource carry that
id and build the synthetic FROM from it. Both sites are needed: initLoop used to
re-derive the id from the resolved storage, which would have re-broken it. So the
source is resolved exactly the way SELECT ... FROM <database>.<table> resolves it,
for every database engine, and nothing has to clear a UUID off the id any more,
because it is a name a user typed.

The resolved handle is no longer a member of anything. StorageLoop::read pins it for
the duration of the query with QueryPlan::addStorageHolder, as Planner.cpp and
InterpreterSelectQuery.cpp do for a plan's source. Keeping it as a member instead
would be a field nothing reads, which -Wunused-private-field rejects.

02722_database_filesystem gains one arm that reads such a table through loop().
Measured on a debug server: it passes on bd4f088, fails with
Code: 81 DB::Exception: Database _table_function does not exist on this branch's
previous commit, and passes here; 50 randomised runs of the file pass. The
argument-form matrix and the sibling carriers are unchanged.

Co-Authored-By: Claude Opus 5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-self PR origin: self-found defect (impact-bar validated) labels Sep 9, 2026
@groeneai

groeneai commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review

An independent model reviewed this change against the code across three rounds, and I adjudicated every
finding. Two of those rounds found a real defect in my own earlier work; both are fixed here. The final
round found one wording nit and nothing else.

  • ❌ loop() over a table-function-backed database would have regressed to UNKNOWN_DATABASE.
    Filesystem, S3 and HDFS databases hand back a storage stamped _table_function.<name>, which no
    catalog lookup resolves, and the branch this change deletes was their read path. Fixed by carrying the
    logical StorageID the user wrote rather than the resolved object's own id, at both sites that build a
    FROM from it. The new arm in 02722_database_filesystem.sh was checked in the inverted direction:
    it passes on master, fails with Code: 81 on the intermediate commit, and passes here.
  • ❌ A source recreated with a different column type sent its columns under the cached header, where
    typeid_cast in SerializationNumber then rejected them, aborting a debug or sanitizer build. Fixed by
    converting after the read, the same Converting columns step StorageTableFunctionProxy::read already
    applies; 05137 gained a drift arm. That conversion also fixes the same abort on the
    ALTER TABLE ... MODIFY COLUMN route, where it is pre-existing on master.
  • ⚠️ The new test's oracles were weaker than its claim. Its DROP was suppressible by the stress
    runner (ignore_drop_queries_probability, now pinned to 0, with a negative control showing the pin is
    load-bearing), and returning from DROP ... SYNC was the only evidence the reference was gone; it now
    also asserts the source left system.dropped_tables.
  • 💡 Known and not fixed here: the comment on StorageLoop::getQueryProcessingStage still names
    inner_storage, the member this change removes. What it explains is still correct; the wording is one
    word out of date.
  • 💡 A RENAME of the source is no longer followed. Deliberate: the reference is the name in
    SHOW CREATE, as for Buffer, Distributed and Merge, and following it on master did not survive a
    restart anyway, since the proxy re-resolves that name on the next read.
  • 💡 Reading through a persisted proxy still does not re-check SELECT on the source. Pre-existing and
    unchanged here: the proxy memoises its nested storage, so every read after the first already bypassed
    it.
  • 💡 ENGINE = Loop reaching the constructor with a null pointer: not applicable, StorageFactory
    refuses that engine before the creator runs (pinned by 03307_forbid_loop_table_function_as_engine).

@clickhouse-gh clickhouse-gh Bot closed this Sep 9, 2026
@clickhouse-gh clickhouse-gh Bot reopened this Sep 9, 2026
@groeneai

groeneai commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, for each defect. Retention: CREATE TABLE t ... MergeTree; CREATE TABLE dl AS loop(currentDatabase(), t); SELECT * FROM dl LIMIT 1; DROP TABLE t SYNC SETTINGS max_execution_time = 20 fails on demand on pristine master (Code: 159 at 21.1 s; unbounded, still running at 190.5 s). Type drift: recreate t with a different column type, or ALTER TABLE t MODIFY COLUMN a non-key column, then read dl, the server aborts. Storage-id derivation: SELECT * FROM loop(<Filesystem database>, '<file>') throws Code: 81 on every run of the intermediate build. Two controls return in 0.08 s on both binaries: a source with no proxy over it, and a proxy created but never read.
b Root cause explained? Three, in sequence. (1) StorageLoop stored the source as a StoragePtr member; the persisted StorageTableFunctionProxy memoises that StorageLoop forever (StorageTableFunction.h:38-50); the background drop task only takes a table whose pointer is unique (DatabaseCatalog.cpp:1597, !isSharedPtrUnique(it->table)), so in_use stays true and waitTableFinallyDropped keeps waiting. (2) Resolving per read makes the source's schema mutable behind the table, while LoopSource still advertises the header cached at CREATE; a port compares only the column count (InputPort::pullData / OutputPort::pushData test chunk.getNumColumns() != header->columns()), so a drifted column reaches NativeWriter::writeData, where SerializationNumber typeid_casts it and abortOnFailedAssertion fires. (3) The id resolved per read was derived from the resolved storage object, and for a table-function-backed database (Filesystem, S3, HDFS) that object's id carries ITableFunction::getDatabaseName()'s synthetic _table_function, which is not a database in DatabaseCatalog.
c Fix matches root cause? Yes, each at its own layer. The extra reference is removed where it lives, on StorageLoop, which keeps a StorageID and resolves per read; the conversion is added in LoopSource::initLoop, the layer that can now produce drift, using the same Converting columns shape as StorageTableFunction.h:193-210 (pinned for the sibling case by 04653_table_function_proxy_prewhere_type_drift); the id is taken from the name the user wrote, in TableFunctionLoop::executeImpl, the one place that knows it, and carried to both consumers that build a FROM from it. No widened bound, no no-random-* tag, no reduced dataset, no defensive check, no _table_function special case, no fallback to the storage's own id; waitTableFinallyDropped and the drop worker's uniqueness gate are untouched (both considered and rejected as symptom guards).
d Test intent preserved / new tests added? New 05137_loop_table_function_drop_source_table (.sql + .reference), five oracles: the DROP ... SYNC returns inside a bound, system.dropped_tables no longer holds the source, the post-drop read raises UNKNOWN_TABLE, a recreated source is picked up again, and a source recreated with a different type is converted. ignore_drop_queries_probability = 0 is pinned so the stress runner's 0.2 cannot no-op a load-bearing DROP. One arm added to 02722_database_filesystem.sh, the file that already owns DatabaseFilesystem behaviour, reading such a table through loop(). No existing test weakened or retagged, and no no-parallel / no-random-settings tag added to either file.
e Both directions demonstrated? Yes, for each defect, through the committed tests. Retention: [ OK ] 0.54 s on the final build, [ FAIL ] 31.47 s Code: 159 TIMEOUT_EXCEEDED on pristine master. Drift: [ FAIL ] 303.85 s Code: 210 with the server dead (Bad cast from type DB::ColumnString to DB::ColumnVector<char8_t>, Received signal Aborted (6)) on a build carrying the retention fix but not the conversion. Storage id, in the inverted direction because it is a regression: the 02722 arm passes on pristine master, fails Code: 81 Database _table_function does not exist on the build before it, and passes on the final build. Plus the stress pin's negative control (the test fails without it under --client-option ignore_drop_queries_probability=1) and 50/50 randomized runs of both files.
f Fix is general across code paths? Measured, not argued. Retention invariant (a storage returned by a table function must not retain a strong reference to a catalog table beyond the query that produced it) swept across every IStorage subclass with a StoragePtr member and every canBeUsedToCreateTable() override: merge, view, remote/cluster and nested remote(<self>, loop(named)) do not pin (0.09-0.10 s on both binaries); the five mergeTree* introspection carriers do pin, need a different remedy, and are disclosed in the PR body. The conversion sits after plan.isInitialized(), so one site covers both initLoop branches, and it is keyed on the mismatch rather than on how it arose, so it also fixes the ALTER MODIFY COLUMN route, which aborts identically on pristine master. The id change removes the dependency on the storage's own id entirely, so loop(db, tbl) resolves exactly as SELECT ... FROM db.tbl does, covering DatabaseS3 and DatabaseHDFS (carriers by code reading, external services needed) with no per-engine branch; DatabaseURL was checked and is not a carrier. registerStorageLoop's null-StoragePtr path is unreachable (ENGINE = Loop -> Code: 80, pinned by 03307_forbid_loop_table_function_as_engine), so no guard was added there.
g Fix generalizes across inputs (params/datatypes/wrappers)? Yes. Argument form: all four measured in both directions on the final build and byte-identical to the first, loop(db.table) and loop('db','table') (159 at 21.09 s -> 0.10 s, post-drop read 1 -> UNKNOWN_TABLE), loop(alias) over an ENGINE = Alias source (same), loop(inner_table_function()) unaffected. Drift shape: type change measured parseable (String '3' -> 3) and unparseable (String 'hello' -> Code: 6 CANNOT_PARSE_TEXT, server alive); column disappearance is rejected earlier by getTable with UNKNOWN_TABLE; identical structure short-circuits on blocksHaveEqualStructure and adds no plan node, so the non-drift path is behaviourally byte-identical. The Filesystem source's table name contains both / and . and resolves correctly, because the synthetic FROM is built from name parts rather than by parsing a string. The adversarial input, a source dropped and recreated under the same name, is a test arm.
h Backward compatible? Yes, measured across binaries and across a restart, and re-measured after the id derivation moved. A data directory written by the pristine-master binary was opened by the fixed one: every persistable loop() form attaches, reads the same values and keeps SHOW CREATE unchanged; on such a table the fixed binary's DROP ... SYNC returns and the post-drop read is UNKNOWN_TABLE; a create/read/restart/read round trip on the fixed binary is stable. No setting default changes, so no SettingsChangesHistory.cpp entry; no on-disk format, no versioning. Pre-existing and unchanged on both binaries: an UNQUALIFIED CREATE TABLE ... AS loop(t) fails Code: 60, because InterpreterCreateQuery calls executeImpl with use_global_context = true. One intended, user-visible change, stated in the changelog entry: reading a persisted loop() table whose source was dropped now raises UNKNOWN_TABLE instead of returning the dropped rows, matching StorageMaterializedView/StorageAlias.
i Invariants and contracts preserved? Yes. The metadata snapshot is still taken in the constructor with CurrentThread::tryGetQueryContext(), deliberately byte-identical, since executeImpl runs with use_global_context = true at CREATE and moving it would change which context reads the schema. getQueryProcessingStage still returns FetchColumns, so the chunk-info contract behind #104863 holds (04244_loop_remote_group_by_chunk_info_104863 green). The branch order in initLoop is safe because executeImpl sets inner_table_function_ast exactly for the inner-table-function form and leaves it null for the named form, mutually exclusive by construction. The conversion is appended before plan.buildQueryPipeline, so the pipeline is built from the converted plan and LoopSource's output-port header stays exactly what ISource was constructed with, the invariant that was being violated; a throw from makeConvertingActions leaves initLoop as an ordinary query exception, the same path the UNKNOWN_TABLE throw already takes. The resolved table is still pinned for the whole query, now by the plan's resource holder (QueryPlan::addStorageHolder) rather than a step member, so a table being read is still protected against a concurrent drop. Nothing on disk changes, so there is no crash/restart re-entry path.

Session id: cron:clickhouse-impl-self-slot-57:20260908-210300

@groeneai

groeneai commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

cc @kssenii @davenger, could you review this? A persisted CREATE TABLE ... AS loop(t) kept a strong StoragePtr to its source, so the drop worker uniqueness gate never passed and DROP TABLE t SYNC never returned; StorageLoop now holds the StorageID the user wrote and resolves it per read, which also makes loop() work against a Filesystem, S3 or HDFS database, whose storages are not registered under their own id.

@clickhouse-gh

clickhouse-gh Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [7951c7c]

Summary: ❌

job_name test_name status info comment
Stateless tests (amd_tsan, s3 storage, targeted) FAIL
05407_distributed_plan_exchange_compression_default FAIL cidb
Stateless tests (arm_asan_ubsan, azure, sequential, 1/2) FAIL
05239_workload_drop_memory_reservation_in_use FAIL cidb

AI Review

Summary

The PR fixes persisted loop tables retaining their source storage and preventing DROP TABLE ... SYNC from completing. It resolves the source by its logical name during reads and converts changed source types to the advertised schema. Reviewed head 7951c7c60824bd968ee179fcd1df7b7ef7767f7a, all changed files, surrounding lifetime and planning paths, and all prior discussion. No actionable findings.

Missing context / blind spots
  • ⚠️ Current-head build, targeted stateless, and bugfix-validation jobs are still pending in the Praktika report. Earlier commit 70f3cae62e1b5056b13eed711f1e7693f5aad379 has 50 passing regression-test runs and successful bugfix validation. Completion of the current jobs closes this validation gap; tests were not rerun locally.
Final Verdict

✅ Approve — no code changes requested. Current-head CI remains pending.

@clickhouse-gh clickhouse-gh Bot added pr-bugfix Pull request with bugfix, not backported by default comp-table-functions Table functions for temporary read/write to external systems (FROM ... tableFunction()). labels Sep 9, 2026
@clickhouse-gh

clickhouse-gh Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 7951c7c60 with master 51ad5655a (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

6 object files changed (+12.58 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Storages/StorageLoop.cpp.o 167.50 KiB 183.54 KiB +16.04 KiB (+9.57%)

719 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

9 translation units recompiled, 21 s compile time in total, 9 of them have a recent master baseline.

Job report

@groeneai

groeneai commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 70f3cae

Every failure below has an owner: a fixing PR, or a full-effort fix task whose fixing-PR link
will be posted here when that PR opens. Only CH Inc sync is exempt, and it is green on this head.

Check / test Reason Owner / fixing PR
AST fuzzer (amd_release, oracle) / TLP Aggregate oracle mismatch on SELECT count() FROM tab STREAM BOUNDED CURSOR ... wrong results: the reference count() is answered from part metadata and so ignores the cursor bound, while the TLP rewrite carries a WHERE and reads the rows inside it #117188 (mine, open)
Stress test (arm_debug) / Logical error: Inconsistent KeyCondition behavior (STID 5182-4365) debug-only key-analysis canary abort; 3 rows over 3 unrelated PRs in 30 days, 0 master rows, first seen 2026-09-03, and unreachable from this diff, which touches only loop() storage and its read step a fix task is created (fixing-PR link to follow here)

Two notes on the rest of the red surface, so the table is not read as incomplete:

  • Bugfix validation (functional tests, amd64) and (aarch64) are GREEN. Their
    02722_database_filesystem FAIL rows are the expected fail-on-master result that this
    validation asks for.
  • The third red conclusion on this head, Finish Workflow at 03:48:50Z, belongs to the
    cancelled first workflow attempt. The live attempt's Finish Workflow is green at 08:23:36Z.

Session id: cron:our-pr-ci-monitor:20260909-083055

@groeneai

Copy link
Copy Markdown
Collaborator Author

Fixing PR for the Inconsistent KeyCondition behavior row on my CI finish ledger here (STID 5182-4365, Stress test (arm_debug), 2026-09-09): #121089.

I confirmed the shape from that job's server log rather than assuming it. The aborting query is SELECT count() FROM test_has_idx_nullable WHERE key_nullable IN (-1, -1, -9223372036854775808, NULL) SETTINGS transform_null_in = 1, and transform_null_in = 1 renames in to nullIn during analysis, so the logged Participating conditions: ... (column 0 in 1-element set) is the null-aware set atom over a bare nullable key that this PR keeps out of the exactness safeguard.

Only ReadFromLoopStep.cpp conflicted. Master removed the pre-analyzer
interpreter branch and added a RepeatedPipelineBuildScope so the joins a
`loop` rebuilds are counted once per pipeline rather than once per pass;
this branch replaces the cached `StoragePtr inner_storage` with a
`StorageID` resolved by name on every read, which orphaned
processed_stage, max_block_size and num_streams.

Both sides are kept: the scope name is threaded through the LoopSource
constructor, member list and makePipe() alongside the StorageID, and the
scope guard stays adjacent to buildQueryPipeline so it still covers
exactly the region master marked. The converting ExpressionStep is added
to the plan before that region, since addStep builds no joins.

The merged tree differs from master by this branch's nine files only, so
no submodule pin and no part of the scope work is reverted.
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 2117022

Every failure below has an owner: a fixing PR, or a full-effort fix task whose fixing-PR link
will be posted here when that PR opens. Only CH Inc sync is exempt, and it is green on this head.

Check / test Reason Owner / fixing PR
Performance Comparison (arm_release, master_head, 4/6) / formats_columns_nullable #1 dashboard-only confirmed_regression on SELECT * FROM table_CSVWithNames_with_nullable_columns LIMIT 1000 FORMAT Null, client_time 8.3ms to 13.0ms (+55.5%). The shard's own report publishes 0 slower queries out of 656 (0 faster, 1 unstable, and that unstable row is this same query, against a +48.6% threshold), so the FAIL arrives purely through the dashboard verdict path. The query is unreachable from this diff, which touches only StorageLoop, ReadFromLoopStep, TableFunctionLoop and two test files, none of which a CSV format read enters. The job additionally reported under-utilized CPU and almost-full disk on the runner. Mergeable Check and PR are red only because they report this leaf #121847 (external, merged 2026-09-23 23:29Z)

Two notes, so the rest of the red surface is not read as unowned:

  • Bugfix validation (functional tests, amd64) and (aarch64) are GREEN. Their
    02722_database_filesystem FAIL rows are the expected fail-on-master result that this
    validation asks for, on a test this PR changes.
  • Ledger rule 3c applies to that owner and I am deliberately not acting on its master-merge
    half. Perf CI: fix false reds of the dashboard gate #121847 merged 18 minutes after this job finished, so it is absent from the tree the job
    built (f14c2a49aa96, measured), but its whole diff is one file, ci/jobs/performance_tests.py,
    and it touches neither DASHBOARD_BLOCKING_TIERS nor perf_dashboard_gate nor any FAIL site,
    so merging master could not clear this leaf. The noisy-query half of the shape is handled in the
    dashboard's confidence scoring, named by the gate owner in
    Perf CI: fail a master_head shard only when its own report also calls the query slower #121090 (comment); that is
    server-side and applies to any later run of this branch without a change here.

Session id: cron:our-pr-ci-monitor:20260923-233131

Conflict in `TableFunctionLoop::executeImpl`: master's `refreshExternalMetadata`
call and this branch's `source_table_id` assignment were both added right after
the `Alias` access check. Both are kept, the refresh first; they are independent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 7951c7c

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Stateless tests (amd_debug, parallel) / 05407_distributed_plan_exchange_compression_default flaky, not from this PR (it changes only loop / StorageTableFunctionProxy): 05407_default prints 1 0 instead of 1 1 under randomized two-level aggregation settings; passes without randomization, fails on master and 16 other PRs in 14 days #127186 (ours, open)
Mergeable Check, PR praktika rollups of the row above #127186 (ours, open)
Sync - CH Inc sync (private, not actionable by me)

Bugfix validation (functional tests, amd64/aarch64) passed: 02722_database_filesystem fails on the pre-fix binary, as intended.

Session id: cron:our-pr-ci-monitor:20261021-170005

@clickhouse-gh clickhouse-gh Bot added comp-simple-engines Lightweight single-node table engines: Log/StripeLog (append-only logs), Buffer (async batching),... and removed comp-table-functions Table functions for temporary read/write to external systems (FROM ... tableFunction()). labels Nov 19, 2026

This branch has not been deployed

No deployments
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 comp-simple-engines Lightweight single-node table engines: Log/StripeLog (append-only logs), Buffer (async batching),... groeneai-origin-self PR origin: self-found defect (impact-bar validated) pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Persisted loop(db, t) table pins its source: DROP TABLE t SYNC never returns

1 participant