Repository navigation
Do not refuse to start when checking whether a table dependency exists fails - #127377
Conversation
…s fails At startup `TablesLoader::removeUnresolvableDependencies` calls `isTableExist` for every loading dependency that is not among the tables being loaded. The answer only selects which warning is logged: the dependency is excluded either way. Some engines cannot answer without reaching their data, and their probe throws: `DatabaseFilesystem` rethrows every `stat` error other than "not found" (a symlink loop, a missing traverse permission) and throws `PATH_ACCESS_DENIED` for a name outside `user_files`, `DatabaseURL` does the same for `file://` tables, and `DatabasePostgreSQL` connects. Nothing caught the exception, so metadata loading stopped and the server or `clickhouse-local --path` did not start, with no way to fix it from SQL. Catch it at that call, log it, and treat the dependency as missing. User statements keep reporting the error, since the probe itself is unchanged. `IDatabase::getCreateTableQuery` guards the same probe in the same way. The 05136 test gains a dictionary over a `Filesystem` table, restarted with the table's file and then the database directory as a symlink loop. Closes ClickHouse#127300 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Condense the two-line comment above the isTableExist probe in TablesLoader to one invariant line. 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-8:20261022-103100 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20261022-100300 |
|
cc @alesapin, could you review this and add the |
|
Workflow [PR], commit [e5a1dc9] Summary: ✅
AI ReviewSummaryReviewed PR #127377 at The focused regression passed 50/50 randomized runs in CI, and functional bugfix validation passed on the same implementation. The final commit only adds a comment. Tests were not rerun locally. Final VerdictStatus: ✅ Approve |
CI finish ledger - bc7841cEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
Session id: cron:our-pr-ci-monitor:20261022-233005 |
The loader asked every database whether a dependency it does not load exists, and the answer only selected a log line. Outside of databases with their own tables (`Atomic`, `Ordinary`, `Replicated`, `Memory`) that question is answered by stat-ing a path or connecting to a remote server (`Filesystem`, `URL`, `S3`, `HDFS`, `MySQL`, `PostgreSQL`, `SQLite`, data lake catalogs, `Overlay`), and a failure there stopped the whole load. Such databases resolve a table on access and never load one, so there is nothing to wait for. Ask only databases with their own tables, which answer from memory, instead of catching what the others throw. `isExternal` is not enough: clickhouse-local's default database is an overlay of `Atomic` and `file://`, which is not external, and checking a name there stats a file of the current directory. The test covers it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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, 10 s compile time in total, 7 of them have a recent master baseline. |
|
Two small notes (non-blocking) — the change itself looks correct: only
|
DatabaseCatalog::isTableExist(StorageID) differs from the name lookup only for an id with a UUID. TablesLoader builds its dependency graph from QualifiedTableName (TablesDependencyGraph::addDependencies), so the nodes it checks never carry one, and DatabaseCatalog::isTableExist has no temporary-table case. Asked in review: ClickHouse#127377 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks, both done.
|
…kup fails RestorerFromBackup::removeUnresolvedDependencies prunes every dependency that is not restored, and called DatabaseCatalog::isTableExist on it only to pick a log line; the dependency is excluded either way. In a database without its own tables that call reaches the data: a Filesystem database throws PATH_ACCESS_DENIED for a name outside user_files (regardless of throw_on_error) or rethrows ELOOP, a PostgreSQL database connects to its server. Nothing caught it, so RESTORE DICTIONARY of a dictionary that CREATE and BACKUP accepted failed (ClickHouse#132345, reproduced on 26.10.5.57, 26.9.31.21, 26.8.39.19, 26.3.66.4). Apply the rule the startup pass TablesLoader::removeUnresolvableDependencies got in ClickHouse#127377: ask isTableExist only of a DatabaseWithOwnTablesBase, which answers from memory; exclude a dependency in any other existing database without a check (its tables are resolved on access); keep the warning for a missing database. Restorer dependency nodes are database-qualified names without a UUID, so the by-name lookup is equivalent. removeTablesIf has no other caller, so both pruning passes now share the rule. EXISTS, SELECT and dictionary loading are unchanged: the restored dictionary still cannot read a file outside user_files. Closes ClickHouse#132345 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes: #127300
Related: #126772
Related: #121705
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a server or
clickhouse-local --pathrefusing to start when a table that another object depends on cannot be reached at startup, for example a DDL dictionary reading a table of aFilesystemdatabase whose file or directory became a symlink loop or lost traverse permission, or of aPostgreSQLdatabase whose server is down. Closes #127300.Description
On 26.9.24.8, a server or
clickhouse-local --pathwhose DDL dictionary reads aFilesystemdatabase table refuses to start withCode: 1001once that table's file becomes a symlink loop (clickhouse-localof 26.3.58.5 too). On master the same happens when the database directory is the loop, since #126772 lets the database itself load.Root cause: at startup
TablesLoader::removeUnresolvableDependenciescallsisTableExistfor each loading dependency that is not being loaded, and the answer only selects the log line: the dependency is excluded either way. In a database without its own tables that call reaches the data:FilesystemandURL('file://...')stat the path and rethrow its errors (PATH_ACCESS_DENIEDfor a name outsideuser_files),PostgreSQLconnects to its server. Nothing catches, so metadata loading stops.Change: the loader asks only databases with their own tables (
DatabaseWithOwnTablesBase:Atomic,Ordinary,Replicated,Memory), which answer from memory. A dependency on any other database is excluded without a check, since such a table is resolved on access.isExternalis not enough: clickhouse-local's default database is an overlay ofAtomicandfile://. User statements keep their errors.Validation:
05136_database_filesystem_missing_path_on_loadgains a dictionary over aFilesystemtable whose file, then directory, becomes a symlink loop, and one over a file read through clickhouse-local's default database. They fail on master and pass with the fix, 30/30 under randomized settings. By hand, a server over both shapes, a name outsideuser_files, aPostgreSQLdatabase with no server andEACCESas non-root: master does not start, the fix does. No test coversPostgreSQLorMySQL(that needs an integration test); they are notDatabaseWithOwnTablesBaseeither, so they take the same path as theFilesystemcases.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/127377]
Version info
26.11.1.1847-master(included in26.11and later)