Skip to content

Fix Files metadata is empty logical error on the object storage queue read path - #113695

Merged
alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-object-storage-queue-metadata-lifetime
Aug 25, 2026
Merged

alexey-milovidov merged 3 commits into
ClickHouse:masterfrom
groeneai:groeneai/fix-object-storage-queue-metadata-lifetime

Conversation

@groeneai

@groeneai groeneai commented Aug 6, 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 Logical error: 'Files metadata is empty' when reading from, altering, or flushing an S3Queue/AzureQueue table whose metadata handle is gone: concurrently with a DROP/DETACH, after a failed startup, or after a failed DROP. Such a table now reports TABLE_IS_DROPPED instead. SYSTEM FLUSH OBJECT STORAGE QUEUE on such a table no longer crashes the server.

Description

StorageObjectStorageQueue::getTableMetadata threw LOGICAL_ERROR whenever files_metadata was null, and createFileIterator calls it first. Plan optimization reaches it via ReadFromObjectStorageQueue::applyFilters, so an ordinary SELECT aborted the server in debug and sanitizer builds (7 occurrences in 90 days, 4 unrelated PRs, 0 on master).

Three reachable states leave an addressable table with a null handle:

  • a concurrent DROP/DETACH: the storage is shut down before any exclusive lock is taken, and for an Atomic database none is taken at all, while a SELECT holds only lockForShare;
  • a failed startup: the catalog entry is created first, and never rolled back;
  • a failed DROP: the database does fallible disk work before detaching (the Logical error: 'Files metadata is empty' with fault injection #93009 route).

The handle was also a plain shared_ptr with no synchronisation, unlike the twelve other members of that class, and waitForPathToBeProcessed read it with no null check, which segfaulted.

The fix guards it with the existing class mutex and gives every operation one snapshot it owns for its whole duration, so a handle observed non-null cannot become null halfway through. getTableMetadata is removed rather than reimplemented on the accessor: it returned a reference into the object the snapshot owns, which a snapshot local to the accessor would leave dangling. Its seven callers each take their own. Where the state is legitimate the code reports TABLE_IS_DROPPED, matching IStorage; the background streaming path returns instead, a null handle there meaning shutdown.

Such a table now reports a clear error; it does not become usable again, since recovery is a DatabaseAtomic/InterpreterDropQuery concern for every engine, out of scope here.

All three reproduce on unpatched master with a stack frame-for-frame identical to the CI report, the concurrent-teardown one with no fault injection (8/8). Three integration tests cover them: pristine master reports 1 failure, the fix 18 passes, 30/30 repeats green.


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

Version info

  • Merged into: 26.9.1.54 (included in 26.9 and later)
  • Backported to: 26.8.1.1996, 26.7.6.34, 26.6.4.39

…ue read path

`StorageObjectStorageQueue::getTableMetadata` asserted that `files_metadata` is
never null, but three reachable states leave a still-addressable table with a
null handle:

  * a concurrent `DROP`/`DETACH`: `InterpreterDropQuery` shuts the storage down
    before it takes any exclusive lock, and for an Atomic database it takes none
    at all, while a `SELECT` holds only `lockForShare`. `shutdown` then resets
    the handle underneath a query that is still building its plan.
  * a failed `startup`: the catalog entry is created first and never rolled back,
    so the table stays in `system.tables` with the handle already reset.
  * a failed `DROP`: `DatabaseAtomic::dropTableImpl` does fallible disk work
    before detaching, so a failure there leaves the table attached and shut down.

Reaching the assertion aborts the server in debug and sanitizer builds, which is
how it surfaces as a stress-test failure. The handle was also a plain
`shared_ptr` with no synchronisation, unlike the twelve other members of that
class, and it was dereferenced unguarded on user-facing paths -- in
`waitForPathToBeProcessed` with no null check at all, which segfaulted.

Guard the handle with the class mutex and give every operation one snapshot that
it owns for its whole duration, so a handle observed non-null cannot become null
halfway through. `getTableMetadata` is removed rather than reimplemented on top
of the accessor: it returned a reference into the object the snapshot owns, so a
snapshot local to the accessor would leave that reference dangling. Each of its
seven callers now takes its own snapshot instead.

Where the state is legitimate, report `TABLE_IS_DROPPED` -- what `IStorage`
itself throws for this condition -- instead of a logical error. On the background
streaming path a null handle means the table is shutting down, so that path
returns rather than logging an error on every poll.

This makes such a table report a clear error. It does not make it usable again;
recovering it is a `DatabaseAtomic`/`InterpreterDropQuery` concern for every
engine and is out of scope here.

Closes ClickHouse#93009
@groeneai

groeneai commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author
Internal second-model review — 1 finding, adjudicated (click to expand)

An independent cold review plus a second model reviewed this change before it was
opened. Verdicts and the evidence behind each are below.

⚠️ Concurrent-drop test may not exercise the plan-construction race — DISAGREE

The concern: the sleepEachRow subquery delays execution, but
createFileIterator runs while the plan is built, so a DROP 1.2 s later would
land after the metadata access and the test could pass on unpatched code.

That requires plan construction to finish before the subquery runs. It is the
other way round, and the pre-fix binary shows it directly.

Five captures of exactly this query shape against the unpatched binary each abort
with Files metadata is empty, and the frame chain is the plan-optimization one:

StorageObjectStorageQueue::createFileIterator
ReadFromObjectStorageQueue::applyFilters
SourceStepWithFilterBase::applyFilters
QueryPlanOptimizations::optimizePrimaryKeyConditionAndLimit
QueryPlanOptimizations::optimizeTreeSecondPass
QueryPlan::optimize
InterpreterSelectQueryAnalyzer::buildQueryPipeline

Had planning completed before the DROP, that abort could not happen. It happens
in 8 of 8 runs.

The ordering explains why. With the analyzer (enable_analyzer defaults to true,
and the stacks above are InterpreterSelectQueryAnalyzer), a scalar subquery is
executed during query-tree resolution:
evaluateScalarSubqueryIfNeeded builds an interpreter and pulls it to completion
(src/Analyzer/Resolve/evaluateScalarSubqueryIfNeeded.cpp:206, :284-299), and
resolution runs in QueryTreePassManager
(src/Interpreters/InterpreterSelectQueryAnalyzer.cpp:256) strictly before
planner.buildQueryPlanIfNeeded and query_plan.optimize (:400-413). So the
subquery is the barrier that holds the plan open across the DROP, which is the
deterministic barrier the finding asks for. Consistent with that, the
scalar-subquery frames are absent from all five abort stacks: the sleep had
already finished when optimize ran.

The barrier is also structural rather than incidental. sleepEachRow is the
per-row variant (src/Functions/sleep.cpp:143), so 15 rows at 0.2 s is 3.0 s of
real sleeping against a 1.2 s drop delay, and the test module raises
function_sleep_max_microseconds_per_block to 1e8 so nothing truncates it.

Independently: reverting createFileIterator's snapshot (mutant M1) reddens
test_select_racing_drop, with the abort carrying the SELECT's own query id.
The arm detects a regression at the exact site.

No code or test change.

💡 New exception missing from a doc comment — noted, not blocking

waitForPathToBeProcessed's header comment
(src/Storages/ObjectStorageQueue/StorageObjectStorageQueue.h:88-95) lists the
exceptions it throws and does not mention the TABLE_IS_DROPPED this change adds
at StorageObjectStorageQueue.cpp:1972.

Also checked and cleared

  • Every remaining files_metadata access is under mutex: after the change the
    member appears at four lines only, three writes and the accessor, all locked.
  • Snapshot lifetimes: for each of the eight tryGetFilesMetadata locals the
    enclosing scope outlives the last use, so nothing borrowed from a snapshot
    outlives it. This is what makes deleting getTableMetadata necessary rather
    than convenient, since it returned a reference into the pointee.
  • No lock held across keeper or object-storage I/O, and no re-entrant acquisition
    of mutex through the new accessor.
  • shutdown publishing the null before the keeper cleanup, while its local copy
    keeps the object alive, is what lets a concurrent reader observe the shut-down
    state; the factory drops its map entry only at zero refcount.
  • getSettings returning defaults on a null handle is a strict improvement: it
    previously reached the assertion, so a single leaked queue table made
    SELECT * FROM system.s3_queue_settings abort a debug server.
  • TABLE_IS_DROPPED is what IStorage throws for this condition
    (src/Storages/IStorage.cpp:70, :97, :120) and nothing catches or
    special-cases it, so it reaches the client unchanged from plan optimization.
  • Two findings raised by the cold review were withdrawn on measurement. One
    claimed two of the three new tests had no unpatched-binary arm: true of the
    pytest A/B, but every route does have one in the native harness. The other
    claimed no run showed the race arm reaching its branch, from a grep over a
    green pytest log; a passing pytest run emits no per-test output at all, so that
    zero measured nothing.

Session id: cron:clickhouse-review-slot-9:20260806-143600

@groeneai

groeneai commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes, three of them, each on demand. Route (a) concurrent teardown, no fault injection of any kind: create an S3Queue table (bogus credentials and an unreachable URL are fine), start SELECT count() FROM q WHERE column1 > (SELECT sum(sleepEachRow(0.2)) FROM numbers(15)) SETTINGS stream_like_engine_allow_direct_select=1, then DROP TABLE q SYNC 1.2 s later: abort 8/8. Route (b): SYSTEM ENABLE FAILPOINT object_storage_queue_fail_startup, CREATE, then the direct SELECT. Route (c): plain_rewritable disk plus plain_object_storage_write_fail_on_directory_create, failed DROP, then the direct SELECT.
b Root cause explained? files_metadata is a plain shared_ptr with no synchronisation. shutdown resets it, startup's failure SCOPE_EXIT_SAFE resets it, and neither the catalog entry for a failed startup nor the one for a failed DROP is rolled back, so a still-addressable table can carry a null handle. getTableMetadata asserted the handle is never null; createFileIterator calls it first, and plan optimization reaches that via ReadFromObjectStorageQueue::applyFilters from optimizePrimaryKeyConditionAndLimit, so the read path hits the assertion and the server aborts in debug and sanitizer builds.
c Fix matches root cause? Yes. It fixes the lifetime and synchronisation of the handle rather than guarding the throw site: the member is TSA_GUARDED_BY(mutex), every operation takes one snapshot it owns for its whole duration, and getTableMetadata is deleted rather than reimplemented on the accessor, since it returned a reference into the snapshot-owned object. TABLE_IS_DROPPED replaces the logical error because the state is reachable, and the compiler now enforces the discipline: reverting one snapshot to an unguarded member read is 3 -Werror thread-safety errors.
d Test intent preserved / new tests added? Three new integration tests, one per reachable state, each asserting TABLE_IS_DROPPED from SELECT, SYSTEM FLUSH OBJECT STORAGE QUEUE and ALTER MODIFY SETTING, plus server survival and the absence of the abort in the server log. No existing test is weakened; the four system.s3_queue_settings/settings tests that pin getSettings's default-settings contract still pass.
e Both directions demonstrated? Yes. Pre-fix: routes (a), (b) and (c) each abort with Logical error: 'Files metadata is empty' and a stack frame-for-frame identical to the CI report, and SYSTEM FLUSH segfaults; four controls stay clean (SELECT without the setting gives Code: 620, system.s3_queue_settings returns 354 rows, a TRUNCATE victim and a SELECT 1 victim are unaffected). Post-fix on build id 626028a330cbae75fa8436231994b0a7b3e1692d: all six report TABLE_IS_DROPPED, server alive, and every control is unchanged. Test level: on pristine master the suite reports 1 failure, after the fix 18 pass.
f Fix is general across code paths? Yes. All 25 direct files_metadata reads and all 7 getTableMetadata callers are converted; only the write sites and the accessor now touch the member. AzureQueue is the same class, so it is covered by construction. ObjectStorageQueueSource receives its handle by value at construction and keeps it alive, so it is not a carrier and is untouched. The other IStreamingStorage implementations (Kafka, Kafka2, NATS, RabbitMQ) have zero occurrences of such a handle.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A for datatypes: this is a storage-lifecycle fix with no column-type dimension. The state dimension is covered instead: both queue modes (unordered in routes a/b, ordered in route c), all three ways the handle becomes null, and all three user-facing entry points that need it.
h Backward compatible? Yes. No setting, no SettingsChangesHistory.cpp entry, no serialization or format change, no public API change. The only observable difference is the error a shut-down-but-attached table reports: TABLE_IS_DROPPED instead of a logical error, which is strictly more accurate and matches what IStorage throws for the same condition.
i Invariants and contracts preserved? The invariant is now stated and enforced: no path may read the handle, or borrow from the object it owns, without taking a snapshot under mutex, handling null, and keeping that snapshot in scope for the whole borrow. getSettings keeps its contract of returning default settings when the metadata is unavailable, rather than throwing. streamToViews and threadFunc return on a null handle instead of raising, since a background poll during shutdown is not an error. No keeper I/O runs under mutex: startup and shutdown copy the handle under the lock and do their keeper work outside it, and shutdown publishes the null before the keeper cleanup so a concurrent reader observes the shut-down state.

Session id: cron:clickhouse-impl-slot-42:20260806-102300

@groeneai

groeneai commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator Author

cc @kssenii @antonio2368, could you review this? files_metadata was an unsynchronised shared_ptr that shutdown reset while a concurrent reader was still building its query plan, so getTableMetadata hit its own Files metadata is empty assertion during plan optimization and aborted debug and sanitizer builds. It is now guarded by the class mutex and every operation takes one snapshot it owns for its whole duration.

@PedroTadim PedroTadim added the can be tested Allows running workflows for external contributors label Aug 7, 2026
@clickhouse-gh

clickhouse-gh Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [75906ad]

Summary: ✅


AI Review

Summary

This PR fixes the files_metadata lifetime bug in the S3Queue / AzureQueue read and background paths by snapshotting the metadata handle under the storage mutex and translating broken-table access to TABLE_IS_DROPPED. One user-visible regression still remains: shut-down-but-still-attached queue tables now fabricate default rows in system.s3_queue_settings / system.azure_queue_settings, so those system tables can report the wrong configuration instead of exposing the real state.

Findings

⚠️ Majors

  • [src/Storages/ObjectStorageQueue/StorageObjectStorageQueue.cpp:1848] Returning a default-constructed ObjectStorageQueueSettings when the metadata handle is gone breaks the contract of system.s3_queue_settings / system.azure_queue_settings. dumpToSystemEngineSettingsColumns still derives changed and alterable from the stored settings_changes, so a leaked queue table after a failed DROP can now show values like keeper_path = '' or mode = 'ordered' even when those settings were explicitly different, sometimes with changed = 1.
  • Suggested fix: reconstruct the rows from the in-memory metadata and the local storage members that still exist (zk_path, local setting copies, etc.), or skip the broken table from the system table instead of returning fabricated defaults.
Tests
  • ⚠️ There is no regression coverage for system.s3_queue_settings / system.azure_queue_settings on a queue table whose metadata handle was cleared by a failed DROP. A small integration check there would catch this fallback.
Final Verdict

⚠️ Needs changes before merge.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 87.00% 86.90% -0.10%
Functions 91.90% 91.90% +0.00%
Branches 79.20% 79.20% +0.00%

Changed lines: Changed C/C++ lines covered: 160/182 (87.91%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 7, 2026
…test

The concurrent-drop arm accepted a clean result as well as the error, so a run in
which the SELECT completed before the DROP satisfied it. That outcome never reads
the metadata after shutdown, so the arm passed against the unfixed server too, and
a future planner change that stopped opening the window would have gone unnoticed
while the test stayed green.

Measured on this branch, three tests per cell, native pytest with per-arm binaries:

  test shape                    old assertion   new assertion
  shipped race                  pass            pass (30 races)
  SELECT finishes before DROP    pass            fail

The second row is the mutant: with the window never entered, the old assertion
passes and the new one fails with `assert 'TABLE_IS_DROPPED' in ''`.

Requiring the error does not make the arm racy. The subquery sleeps 3 seconds and
the DROP lands at 1.2 seconds, so the window is open by construction: 26 of 26
consecutive races returned TABLE_IS_DROPPED, including 6 with the DROP delayed to
2.5 seconds, which leaves 0.5 seconds of margin. The absence of the logical error
in the server log is kept as a separate assertion, since a query-level error alone
does not prove the server survived.
@clickhouse-gh

clickhouse-gh Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 75906ad43 with master 0df24796b (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of 632b80920; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 708.96 MiB 705.93 MiB -3.03 MiB (-0.43%)

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.

Compile time of recompiled translation units

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

Job report

@kssenii kssenii self-assigned this Aug 7, 2026
const auto & table_metadata = getTableMetadata();
auto metadata = tryGetFilesMetadata();
if (!metadata)
return settings;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Returning a default-constructed ObjectStorageQueueSettings here makes system.s3_queue_settings / system.azure_queue_settings lie about a queue table that is still attached after a failed DROP.

StorageSystemObjectStorageQueueSettings always calls storage.getSettings(), and dumpToSystemEngineSettingsColumns() derives changed / alterable from settings_changes in the in-memory metadata rather than from this fallback. That means explicit values like keeper_path, mode = 'unordered', or processing_threads_num = 16 now get reported as their defaults, sometimes with changed = 1, which breaks the system-table contract and hides the real configuration while debugging the leaked table.

Can we either reconstruct the values from the in-memory metadata plus the local members that still exist here, or skip this broken table from system.*_queue_settings instead of fabricating defaults?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I checked this against the source and against CI history, and I am not making the change.

Reachability is right: StorageSystemObjectStorageQueueSettings.cpp:66 iterates every attached table and :56 calls getSettings() with no state filter. The changed/alterable inconsistency is real too, and slightly worse than described: alterable goes through isSettingChangeable(name, mode), and mode is one of the fields that falls back. The default is ORDERED, so an unordered table is reported against the ordered changeability set, and 5 settings flip (processing_threads_num, tracked_files_limit, tracked_file_ttl_sec, enable_hash_ring_filtering, buckets).

Two things argue against acting on it here.

The fallback is not introduced by this PR. At the merge base f889715f8, getSettings() already reads:

ObjectStorageQueueSettings settings;
/// If startup() for a table was not called, just use the default queue settings
if (!startup_finished)
    return settings;

A table whose startup() failed already reports default rows on master today. This PR widens the same behaviour to a second state (shut down, handle dropped); it does not create it.

Skipping the table is a measured regression. The only lever available inside getSettings() is a throw, and fillData has no try/catch, so one leaked queue table takes down the whole scan and every healthy table's rows with it. That is the failure this PR exists to remove, and it is the family's largest carrier in practice: over the last 40 days, of 25 Files metadata is empty aborts across 22 PRs, 11 carry the frames StorageObjectStorageQueue::getSettings -> StorageSystemObjectStorageQueueSettings::fillData.

On reconstructing the values: 26 of the 45 settings already come from members that survive shutdown and are correct. The other 19 come from keeper via the handle that is gone. settings_changes does track ALTER, but it only records names that were explicitly specified, so anything left unset at CREATE still reads back as its default. That closes part of the gap and leaves the rest unchanged, which seems worth doing on its own, but not as part of a PR scoped to reporting a clear error rather than making a leaked table readable.

Net effect today is a cosmetically wrong row for a table that is already broken, versus an abort that loses every row. I am leaving the fallback as is and not opening a follow-up for the row accuracy.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 24, 2026
@alexey-milovidov alexey-milovidov added the blocker This issue / pr blocks a new release label Aug 24, 2026
Merged via the queue into ClickHouse:master with commit f7901a4 Aug 25, 2026
357 of 358 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Aug 25, 2026
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 25, 2026
clickhouse-gh Bot pushed a commit that referenced this pull request Aug 25, 2026
… on the object storage queue read path
clickhouse-gh Bot added a commit that referenced this pull request Aug 25, 2026
Backport #113695 to 26.8: Fix `Files metadata is empty` logical error on the object storage queue read path
robot-ch-test-poll4 added a commit that referenced this pull request Aug 27, 2026
Cherry pick #113695 to 26.6: Fix `Files metadata is empty` logical error on the object storage queue read path
robot-clickhouse added a commit that referenced this pull request Aug 27, 2026
… on the object storage queue read path
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Aug 27, 2026
clickhouse-gh Bot added a commit that referenced this pull request Aug 29, 2026
Backport #113695 to 26.6: Fix `Files metadata is empty` logical error on the object storage queue read path
clickhouse-gh Bot added a commit that referenced this pull request Aug 29, 2026
Backport #113695 to 26.7: Fix `Files metadata is empty` logical error on the object storage queue read path
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Sep 4, 2026
…ical error on the object storage queue read path
@groeneai

Copy link
Copy Markdown
Collaborator Author

26.3 does not have this fix, and the same LOGICAL_ERROR now aborts the server in Stress test (amd_ubsan) on 26.3 @ 9d1b484 (report). The stack is getTableMetadata <- checkAlterIsPossible <- InterpreterAlterQuery::executeToTable, the ALTER path this PR changed to throw TABLE_IS_DROPPED. The query was ALTER TABLE t_legacy MODIFY SETTING ... from 05314_s3queue_legacy_prefix_secret_masking, which reached 26.3 with the backport of #123060 on 2026-09-30.

The backport labels here start at v26.6-must-backport, and no 26.3 cherry-pick was ever opened. A 26.3 backport needs v26.3-must-backport plus removing pr-backports-created, because the automation skips PRs that carry it (receive_prs_for_backport in ci/tools/cherry_pick.py).

The cherry-pick onto the current 26.3 will conflict in StorageObjectStorageQueue.cpp: 3 hunks, all next to code that exists only on master (the error-code list, the SYSTEM STOP/PAUSE branch of the streaming loop, waitForPathToBeProcessed). The header, test_5.py and the new config apply cleanly. If the cherry-pick is opened, I will push a resolution for it to my fork.

antonio2368 added a commit that referenced this pull request Nov 5, 2026
The new test `05493_s3queue_settings_system_table_hide_secrets` reads
`system.s3_queue_settings`, which calls `StorageObjectStorageQueue::getSettings`
for every queue table on the server. When a concurrent `DROP` shuts a queue
table down, `shutdown` resets `files_metadata` while `startup_finished` stays
set, and `getTableMetadata` throws the logical error `Files metadata is empty`.
The same failure happened on the backport of this PR to the private
release/26.4 branch.

This is the part of #113695 that
`getSettings` needs (26.3 does not have that PR): `files_metadata` is set and
reset under `mutex`, `tryGetFilesMetadata` takes one snapshot of it, and
`getSettings` returns the default settings when the table is shut down.

PR: #129469

Co-Authored-By: Claude Opus 5.5 <[email protected]>
leshikus pushed a commit that referenced this pull request Nov 13, 2026
The new test `05493_s3queue_settings_system_table_hide_secrets` reads
`system.s3_queue_settings`, which calls `StorageObjectStorageQueue::getSettings`
for every queue table on the server. When a concurrent `DROP` shuts a queue
table down, `shutdown` resets `files_metadata` while `startup_finished` stays
set, and `getTableMetadata` throws the logical error `Files metadata is empty`.
The same failure happened on the backport of this PR to the private
release/26.4 branch.

This is the part of #113695 that
`getSettings` needs (26.3 does not have that PR): `files_metadata` is set and
reset under `mutex`, `tryGetFilesMetadata` takes one snapshot of it, and
`getSettings` returns the default settings when the table is shut down.

PR: #129469

Co-Authored-By: Claude Opus 5.5 <[email protected]>
BorisTyshkevich pushed a commit to BorisTyshkevich/ClickHouse that referenced this pull request Nov 15, 2026
The test raced `DROP TABLE ... SYNC` against a direct `SELECT` by wall
clock: the `SELECT` kept its plan open for ~3 s in a scalar subquery and
pytest sent the `DROP` 1.2 s later, so the `DROP` had to reach the server
within ~1.8 s. In `Integration tests (amd_msan, targeted)` on ClickHouse#112928 the
`DROP`'s client needed 2.23 s to connect, the `SELECT` read the live
metadata first and returned 0 without an error, and the assertion
`'TABLE_IS_DROPPED' in ''` failed.

Add a one-shot pause failpoint `object_storage_queue_pause_in_direct_select`
in `StorageObjectStorageQueue::read()`, after the table is opened and
before the read path takes the metadata handle. It parks the query thread
during planning, never a pipeline worker inside `IProcessor::work()`.
The test now enables it, starts the `SELECT`, waits for the pause, runs
`DROP TABLE` (not `SYNC`: that waits for the paused `SELECT` to release
the table), disables the failpoint and asserts `TABLE_IS_DROPPED`. One
deterministic pass replaces the 10 sleep-based iterations. Same pattern as
`nats_pause_before_checking_direct_select_connection` (ClickHouse#125494).

Related: ClickHouse#112928
Related: ClickHouse#113695

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocker This issue / pr blocks a new release can be tested Allows running workflows for external contributors groeneai-origin-ci-master PR origin: master/nightly CI monitoring finding pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.6-must-backport v26.8-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants