Skip to content

Do not list tables of data lake catalogs and Remote databases before shutdown - #133669

Merged
alexey-milovidov merged 3 commits into
masterfrom
fix-shutdown-enumerating-datalake-catalogs
Nov 25, 2026
Merged

alexey-milovidov merged 3 commits into
masterfrom
fix-shutdown-enumerating-datalake-catalogs

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Related: #133447
Related: #118985

DatabaseCatalog::shutdownImpl lists the tables of every user database to flush Buffer tables before any database goes away (#118985). For a DataLakeCatalog database, getTablesIterator initializes the catalog client and requests the table list from the catalog; for a Remote database it requests it from another server. When that server is unreachable, the request is retried with a backoff and the server does not stop. In the stress test below the main thread sleeps in ReadWriteBufferFromHTTP::waitBeforeRetry under RestCatalog::loadConfig ← DatabaseDataLake::getTablesIterator ← DatabaseCatalog::shutdownImpl, and the check reports Possible deadlock on shutdown (see gdb.log), after which the server is killed.

These databases hold no Buffer tables, so they are skipped in this loop. An Overlay database is skipped as well: it forwards the listing to its sources, which can be such databases, and the StorageAlias tables it returns hold no buffered rows.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=133447&sha=23b710d2e229f81edb3e90504add23c04bd6526f&name_0=PR&name_1=Stress%20test%20(amd_debug)

No test is added: the hang needs a catalog that becomes unreachable before the server stops, and it is what the stress test already exercises. Only the changed translation units were compiled locally.

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):

The server no longer requests the list of tables from a data lake catalog or a Remote database while shutting down, which delayed the shutdown for a long time when the catalog or the remote server was unreachable.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.12.1.479-master (included in 26.12 and later)

…e shutdown

`DatabaseCatalog::shutdownImpl` enumerates the tables of every user database to
flush `Buffer` tables before any database goes away. For a `DataLakeCatalog`
database, `getTablesIterator` initializes the catalog client and requests the
table list from the catalog; for a `Remote` database it requests it from another
server. When that server is unreachable, the request is retried with a backoff,
and the server does not stop: the main thread sleeps in
`ReadWriteBufferFromHTTP::waitBeforeRetry` under `RestCatalog::loadConfig`, and
the stress test reports "Possible deadlock on shutdown (see gdb.log)".

These databases hold no `Buffer` tables, so skip them in this loop.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=133447&sha=23b710d2e229f81edb3e90504add23c04bd6526f&name_0=PR&name_1=Stress%20test%20(amd_debug)
Related: #133447

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f246ec2]

Summary: ✅


AI Review

Summary

The PR avoids remote table enumeration during the pre-shutdown Buffer drain by skipping data lake catalogs, remote databases, and Overlay databases that expose other databases' tables. The earlier Overlay finding is fixed in f246ec2d38a2; no actionable findings remain. The supplied stress trace supports the diagnosis, and the author's documented reason for omitting a dedicated shutdown timing test is reasonable for this narrow change.

Missing context / blind spots
  • ⚠️ CI for the reviewed head is still running. No ClickHouse binary is available in this job, so runtime verification relies on CI.
Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Nov 23, 2026
Comment thread src/Interpreters/DatabaseCatalog.cpp Resolved
@clickhouse-gh clickhouse-gh Bot added the comp-database-engines Database engine implementations (e.g., Atomic/Replicated) and database-level behavior. label Nov 23, 2026
alexey-milovidov and others added 2 commits November 25, 2026 08:13
…down

`DatabaseOverlayReadOnly::getTablesIterator` forwards the listing to its
source databases, so an `Overlay` over a data lake catalog or a `Remote`
database still requested the table list from another server in
`DatabaseCatalog::shutdownImpl`, although the source itself is skipped.

Add `IDatabase::ownsTables`, which is false for `DatabaseOverlayReadOnly`,
and skip such databases in the pass that flushes `Buffer` tables. The
tables it returns are `StorageAlias` objects, which hold no buffered rows,
and its sources are visited by the same loop on their own.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing f246ec2d3 with master 1c87825f4 (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.

Compile time of recompiled translation units

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

Job report

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok.

@alexey-milovidov alexey-milovidov self-assigned this Nov 25, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 25, 2026
Merged via the queue into master with commit c2e2d29 Nov 25, 2026
383 of 384 checks passed
@alexey-milovidov
alexey-milovidov deleted the fix-shutdown-enumerating-datalake-catalogs branch November 25, 2026 13:58
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-database-engines Database engine implementations (e.g., Atomic/Replicated) and database-level behavior. pr-bugfix Pull request with bugfix, not backported by default pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants