Repository navigation
Fix flaky test_refreshable_mv_in_replicated_db - #107132
nikitamikhaylov merged 1 commit into
Conversation
SYSTEM SYNC DATABASE REPLICA only waits for the DDL log pointer, which on a Replicated database replica is committed (inside createTable) before the table's startup() runs. A refreshable MV registers its refresh task into the RefreshSet only in StorageMaterializedView::startup(), so SYNC can return before the task is registered. A following SYSTEM WAIT/TEST VIEW then calls getRefreshTasks(), finds nothing, and throws 'Refreshable view ... doesn't exist' (BAD_ARGUMENTS). Wait until the view is registered (visible in system.view_refreshes) after each SYSTEM SYNC DATABASE REPLICA, before issuing SYSTEM *VIEW commands. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Pre-PR validation gate:
Session: cron:clickhouse-worker-slot-23:20260611-014800 |
|
cc @al13n321 — could you review this? It fixes the chronic flaky |
|
Workflow [PR], commit [1d8880f] Summary: ✅ AI ReviewSummaryThis PR makes Final VerdictStatus: ✅ Approve |
LLVM Coverage Report
Changed lines: No C/C++ source files changed — skipping uncovered code analysis. Newly covered by added/modified tests: 270 line(s), 38 function(s) across 98 file(s) · Details Top files
|
895c73c
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Fixes chronic flakiness of
test_refreshable_mv/test.py::test_refreshable_mv_in_replicated_db.The test fails intermittently with:
right after a
SYSTEM SYNC DATABASE REPLICA re, onSYSTEM WAIT VIEW/SYSTEM TEST VIEW.Root cause: when a Replicated database replica applies the replicated
CREATE MATERIALIZED VIEWlog entry, the ZooKeeperlog_ptrnode is written as part of the metadata transaction that is committed insidedatabase->createTable(), beforeIStorage::startup()runs. The refresh task is only registered into theRefreshSetlater, inStorageMaterializedView::startup()->RefreshTask::startup().SYSTEM SYNC DATABASE REPLICAwaits only for the log pointer, so it can return before the refresh task is registered. A followingSYSTEM WAIT/TEST/REFRESH VIEWthen callsgetRefreshTasks(), finds nothing in theRefreshSet, and throwsBAD_ARGUMENTS. The same file already documents this (system sync database replicadoes not guarantee a replicated object is fully initialized).Fix is test-side only: after
SYSTEM SYNC DATABASE REPLICA, wait until the view is registered (visible insystem.view_refreshes) before issuingSYSTEM *VIEWcommands.system.view_refresheslists whatever is in theRefreshSetand never throws for a missing view, so it is a safe barrier. No assertions are weakened and no settings are pinned.Reproduced deterministically by setting the existing debug server setting
startup_mv_delay_mshigh (it sleeps inStorageMaterializedView::startup()before registering the refresh task): the test fails reliably without this change and passes with it. Validated with the default config as well.Version info
26.6.1.684