Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens system.tables enumeration against nullptr StoragePtr values returned by database table iterators (e.g., during concurrent DROP / lazy-loading scenarios), preventing dereference crashes during system table queries.
Changes:
- Skip tables with
nullptrStoragePtrindetail::getFilteredTables()when engine/uuid columns are needed. - Skip
nullptrStoragePtrinTablesBlockSourceinstead of throwingLOGICAL_ERROR. - Remove the now-unused
ErrorCodes::LOGICAL_ERRORforward declaration.
Add a `datalake_try_get_table_return_nullptr` failpoint that makes `DatabaseDataLake::tryGetTableImpl` return nullptr, simulating a metadata fetch failure. Use it in a new integration test that exercises the three `system.tables` query paths (engine filter, `SELECT *`, `count(engine)`) to verify no crash occurs. Also update the stale comment on `IDatabaseTablesIterator::table` which referenced the removed `DatabaseLazy` — the actual current source of nullptr is `DatabaseDataLake`. ClickHouse/clickhouse-core-incidents#1434
|
Upgrade check (amd_release) failure See #98800 |
|
The LLVM Coverage job failure in this PR is caused by a bug introduced in #96738 — the job crashes when a PR has no C++ source code changes. The fix is in #99032. Since this branch is in a fork, I can't merge it directly — please merge master once #99032 lands, or cherry-pick the fix. cc @alexbakharew |
|
I'm confused. It looks like |
LLVM Coverage Report
PR changed lines: PR changed-lines coverage: 91.18% (31/34) |
Backport #98792 to 26.2: Fix crash in system tables
Linked issues
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixes a crash where we could de-reference a null pointer in system tables created between the time when we snapshot the tables in the
IDatabaseTablesIterator::table()call and the tables changing in another thread during later iteration.Documentation entry for user-facing changes
This fixed a crash (https://github.com/ClickHouse/clickhouse-core-incidents/issues/1434) where, when querying system tables, we would get a null pointer and crash.
I've also got rid of a logical error. Now if we know the table pointer is null, and no good, we should wave and walk on by.
Note
Medium Risk
Touches
system.tablesenumeration logic used broadly across the server; behavior changes from throwing/crashing to silently skipping tables whenIDatabaseTablesIterator::table()is null, which could mask transient issues but prevents crashes.Overview
Fixes a crash in
system.tablesby treatingIDatabaseTablesIterator::table()as nullable and skipping entries where theStoragePtris null (both in filter pre-scan and the mainfillDataiteration), rather than dereferencing or throwing.Adds a DataLake-specific failpoint (
datalake_try_get_table_return_nullptr) to forceDatabaseDataLake::tryGetTableImpl()to returnnullptr, updates iterator docs to reflect metadata-fetch failures, and adds an integration test that reproduces the incident and verifiessystem.tablesqueries return empty results instead of crashing.Written by Cursor Bugbot for commit 788ad6e. This will update automatically on new commits. Configure here.
Version info
26.3.1.54226.2.8.14