Repository navigation
Conversation
`DatabaseCatalog::shutdownImpl` collects the tables of every non-predefined database with `getTablesIterator` to flush `Buffer` tables before any database shuts down (ClickHouse#118985). For an external database that call is a request to its remote side: a `DataLakeCatalog` database loaded from metadata builds its catalog lazily on that call (the REST catalog retries `/v1/config` 10 times, ~33 s when nobody answers), `Remote` and `Cluster` query the remote server, `MySQL` and `PostgreSQL` connect. An external database cannot hold a `Buffer` table (`IDatabase::isExternal`), so the listing never finds one, and each unreachable database delays the shutdown sequentially. Since ClickHouse#131994 the Stress server-side fuzzer clones `CREATE DATABASE` under fuzzed names, so clones of a test's DataLakeCatalog databases outlive its mock catalog, and the final shutdown of the Stress jobs walks into the dead endpoint once per clone until the harness kills the server ("Possible deadlock on shutdown", reported as an allowed OOM). Skip external databases in that loop, as every other enumerator of internal table engines already does. Closes ClickHouse#126060 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 finding) plus my own review (1 nit).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261121-144509 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261121-141200 |
|
Workflow [PR], commit [20cb661] Summary: ✅
AI ReviewSummaryThe PR skips external databases when collecting tables for the shutdown Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 13 s compile time in total, 7 of them have a recent master baseline. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Server shutdown no longer lists the tables of external databases (
DataLakeCatalog,MySQL,PostgreSQL,Remote, ...), which delayed it by about 30 seconds for each such database whose remote side did not answer.Description
Closes: #126060
Related: #118985 (added the
Bufferdrain)Related: #131994 (exposes it in Stress)
Related: #128923 (has the same condition inside its shutdown rewrite)
Failure on master (
Possible deadlock on shutdown, thensignal 9, on 6 Stress flavours since #131994): https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?REF=master&sha=2a2f57466616f97b3f6cbbf4dbe29b85b5811dfe&name_0=MasterCI&name_1=Stress%20test%20%28arm_debug%29Before any database shuts down,
DatabaseCatalog::shutdownImpllists the tables of every user database to flushBuffertables. For an external database that listing is a request to its remote side: aDataLakeCatalogdatabase loaded from metadata builds its REST catalog there and retries/v1/configfor about 33 s when nobody answers,Remotequeries the remote server,MySQLandPostgreSQLconnect. An external database cannot hold aBuffertable, so nothing is ever found. Since #131994 the Stress fuzzer clonesCREATE DATABASE; the clones of a test'sDataLakeCatalogdatabases outlive its mock catalog, and the final shutdown walks into the dead endpoint once per clone until the harness kills the server. #131994 only exposes this, so this PR fixes the listing instead of reverting it.The loop now skips
isExternal()databases, as the other enumerators of internal table engines (system.replicas,system.mutations, ...) already do. One edge: aBuffertable attached into aPostgreSQLdatabase withuse_table_cache(a definition theMySQLengine refuses) is no longer flushed early, as before #118985.Validation (debug builds): the new test fails on master (13 connections to its listener, 34 s: 10 from
DataLakeCatalog, 3 fromRemote) and passes with the fix (0, 1 s), 50/50 randomized runs. A server with two unreachableDataLakeCatalogdatabases loaded from metadata shuts down in 67 s on master and 3 s with the fix.test_buffer_flush_on_shutdownpasses 13/13.Workflow [PR]
Sync PR [sync-upstream/pr/133406]