Repository navigation
Fix crash on REFRESH ... DEPENDS ON shadowed by a temporary table - #107156
Conversation
Pre-PR validation gate
Session id: cron:clickhouse-worker-slot-3:20260611-063900 |
|
cc @al13n321 @tuanpach — could you review this? It fixes the |
|
Workflow [PR], commit [8d85c5e] Summary: ✅
AI ReviewSummaryThis PR fixes the Final VerdictStatus: ✅ Approve |
|
@groeneai I am not sure if we should allow materialized views to/with temporary tables. Is that going to work at the moment? |
|
@PedroTadim good question. I dug into the current behavior on the fixed build. Short version: this PR does not make MV depend on a temporary table. With the fix a Details, all tested locally on this branch:
Regression test |
|
CI finished on HEAD Session id: cron:our-pr-ci-monitor:20260611-160000 |
|
@groeneai, fix the pre-existing flaky test, |
fee14ca to
0b7d352
Compare
|
@alexey-milovidov This one is already fixed and merged: #107254 "Fix flaky test 04027_system_start_replicated_view" (merged 2026-06-12, approved by nikitamikhaylov). Root cause was an asymmetric wait budget in the test, not an engine bug: the post-resume Verification: master HEAD That 06-11 sighting flaked here because this branch was ~3360 commits behind master and still carried the old 15s test. I've just rebased #107156 onto current master, so its CI now runs the fixed version. Sorry for the stale ledger comment above — by the time it was posted the fix PR had not landed yet. |
0b7d352 to
253a3d5
Compare
Pre-PR validation gate (test-strengthening update, 253a3d5)
Session id: cron:clickhouse-worker-slot-0:20260619-223800 |
253a3d5 to
d1c5d0e
Compare
Pre-PR validation gate(For the SELECT/DEPENDS ON database-divergence fix raised in the InterpreterCreateQuery.cpp review.)
Session id: cron:clickhouse-worker-slot-1:20260619-233900 |
|
@groeneai, fix fast test and address review. |
Fixes a server crash (issue ClickHouse#106737, STID 2508-3e7b) when a refreshable materialized view has a `REFRESH ... DEPENDS ON <name>` dependency whose unqualified name matches a temporary table (or a CTE name). RefreshTask::create and RefreshTask::alterRefreshParams turned the DEPENDS ON entries into StorageIDs straight from the AST. AddDefaultDatabaseVisitor skips qualifying a bare name that matches a temporary table or CTE, so such a dependency kept an empty database. On the first scheduling pass StorageID::getFullTableName() threw UNKNOWN_DATABASE "Database name is empty", the catch-all in RefreshTask::doScheduling re-raised it as a LOGICAL_ERROR and the server aborted. The bad definition was persisted, so the server then crash-looped on restart. Resolve any still-unqualified dependency against the view's database in RefreshTask::create / alterRefreshParams. This is the right database for the no-session paths (attach-from-metadata on restart, background scheduling) and matches the database the AddDefaultDatabaseVisitor would have used for a non-shadowed name. This change is limited to the empty-database dependency. It does not change how a refreshable MV's SELECT or DEPENDS ON clause resolves unqualified names in the normal (non-shadowed) case: both still resolve in the session database at CREATE time, exactly as before. Closes: ClickHouse#106737 Co-Authored-By: Claude Opus 4.8 <[email protected]>
d1c5d0e to
8d85c5e
Compare
Pre-PR validation gate(For the pivot to the minimal crash fix after the previous push broke the pre-existing master test
Session id: cron:clickhouse-worker-slot-4:20260620-004100 |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 17/17 (100.00%) | Lost baseline coverage: none · Uncovered code |
|
Hi @groeneai @alexey-milovidov — while reviewing this PR I found the following:
Could you review the test PR and add the |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed a server crash (
LOGICAL_ERROR"Unexpected exception in refresh scheduling", followed by a crash-loop on restart) when a refreshable materialized view has aREFRESH ... DEPENDS ON <name>dependency whose unqualified name matches a temporary table or a CTE name.Description
Closes: #106737
REFRESH ... DEPENDS ON <name>dependencies are built intoStorageIDs directly from the AST inRefreshTask::create/RefreshTask::alterRefreshParams.AddDefaultDatabaseVisitorskips qualifying a bare name that matches a temporary table or a CTE, so such a dependency kept an empty database. On the first scheduling passStorageID::getFullTableName()threwUNKNOWN_DATABASE"Database name is empty", the catch-all inRefreshTask::doSchedulingre-raised it as aLOGICAL_ERRORand the server aborted; the bad definition was persisted, so the server then crash-looped on restart.Fix: resolve any still-unqualified dependency against the view's database in
RefreshTask::create/alterRefreshParams. This is the correct database for the no-session paths (attach-from-metadata on restart, background scheduling) and matches the databaseAddDefaultDatabaseVisitorwould have used for a non-shadowed name.The change is limited to the empty-database dependency. It does not change how a refreshable MV's
SELECTorDEPENDS ONclause resolves unqualified names in the normal (non-shadowed) case: both still resolve in the session database atCREATEtime, as before.The regression test
04329_refreshable_mv_depends_on_database_qualification.shreproduces the original crash via a temporary table shadowing the dependency name, and assertssystem.view_refreshessettles atMissingDependencieswith an emptyexception(instead ofDisabledwith an exception), so it catches the regression in non-sanitizer functional CI as well as in debug/sanitizer builds where the catch-all aborts. It also covers the detach/attach (attach-from-metadata) path.CI report for the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107156&sha=d1c5d0ef9aad5b1c5c71acda4fb8e98495cf0ab7&name_0=PR
Found by issue #106737 (STID 2508-3e7b).
Version info
26.6.1.1076