Skip to content

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 into
backport/26.6/113695from
cherrypick/26.6/113695
Aug 27, 2026
Merged

robot-ch-test-poll4 merged 5 commits into
backport/26.6/113695from
cherrypick/26.6/113695

Conversation

@robot-ch-test-poll2

Copy link
Copy Markdown
Contributor

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-pick locally.
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:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

groeneai and others added 4 commits August 6, 2026 14:26
…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
@robot-ch-test-poll2 robot-ch-test-poll2 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Aug 25, 2026
…ypick/26.6/113695

# Conflicts:
#	src/Storages/ObjectStorageQueue/StorageObjectStorageQueue.cpp
@robot-ch-test-poll4
robot-ch-test-poll4 merged commit 86259c8 into backport/26.6/113695 Aug 27, 2026
1 check passed
@robot-ch-test-poll4
robot-ch-test-poll4 deleted the cherrypick/26.6/113695 branch August 27, 2026 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants