Repository navigation
Cherry pick #113695 to 26.6: Fix Files metadata is empty logical error on the object storage queue read path - #116218
Merged
robot-ch-test-poll4 merged 5 commits intoAug 27, 2026
Conversation
…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 #93009
…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.
…queue-metadata-lifetime Fix `Files metadata is empty` logical error on the object storage queue read path
…ypick/26.6/113695 # Conflicts: # src/Storages/ObjectStorageQueue/StorageObjectStorageQueue.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Original pull-request #113695
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job