Repository navigation
Refreshable MV dependencies overhaul - #104440
Conversation
|
Workflow [PR], commit [bd8d761] Summary: ✅ AI ReviewSummaryThis PR overhauls refreshable materialized view dependency handling ( Findings
💡 Nits
Final VerdictStatus: Minimum required actions:
|
|
|
||
| UInt64 backoff_ms = 100; | ||
| const UInt64 max_backoff_ms = 1000; | ||
| const int max_attempts = 10; |
There was a problem hiding this comment.
This adds a hard cap of 10 retries with exponential backoff (~6.3s total) before throwing TABLE_UUID_MISMATCH.
That can make SYSTEM WAIT VIEW and dependency-triggered refreshes fail spuriously on slow replicas (replication lag or metadata propagation can exceed this window even though the table eventually appears). Previously this wait was open-ended and only failed on an actual refresh error/drop.
Please avoid a fixed short timeout here (or gate it behind a setting with a much safer default) so we do not convert transient lag into false refresh failures.
There was a problem hiding this comment.
The fixed retry window is still here (max_attempts = 10 with exponential backoff up to 1s, i.e. ~6.5s total).
I still think this is too short for replicated catalogs under lag: SYSTEM WAIT VIEW and dependency sync can fail with TABLE_UUID_MISMATCH even when the correct table appears shortly after. This converts transient replica lag into user-visible refresh failures.
Please avoid a hard short timeout here (or make it configurable with a safer default).
There was a problem hiding this comment.
This is still unresolved in the current code.
waitForLatestTargetTable still has a fixed max_attempts = 10 with exponential sleeps up to 1 second, then throws TABLE_UUID_MISMATCH.
That keeps the wait window around ~6.5 seconds, which is too short for realistic replication/catalog lag. This path is now used not only by SYSTEM WAIT VIEW, but also by dependency-triggered refresh via syncForDependentRefresh, so transient lag can still be converted into user-visible refresh exceptions.
Please remove the hard short timeout (or make it configurable with a safer default) so transient lag does not fail otherwise recoverable refresh flows.
There was a problem hiding this comment.
This is still live in the current code.
waitForLatestTargetTable still hard-fails after max_attempts = 10 (~6.5s total with exponential backoff). On replicated catalogs, table/metadata propagation can exceed this window under lag or recovery, so SYSTEM WAIT VIEW and dependency pre-sync can raise TABLE_UUID_MISMATCH even when the correct table appears shortly after.
Please avoid a fixed short timeout here (or make it configurable with a safer default and keep waiting by default).
There was a problem hiding this comment.
Seems fine, I'd assume >6.5s is rare, and it's ok for WAIT VIEW to error out instead of stalling for a long time.
There was a problem hiding this comment.
Still seeing this as unresolved in the current code. waitForLatestTargetTable still has max_attempts = 10 with exponential backoff up to 1s (src/Storages/MaterializedView/RefreshTask.cpp, around lines 569-610), so it throws TABLE_UUID_MISMATCH after roughly 6.5s.
That turns transient metadata/replication lag into user-visible failures in two paths now using this helper: SYSTEM WAIT VIEW and dependency pre-sync (syncForDependentRefresh for non-APPEND). On replicated catalogs, table visibility can legitimately exceed this window during replica restart/recovery or Keeper reconnect.
Please avoid a hard short timeout here (or make it configurable with a conservative default), so these paths wait for convergence instead of failing on temporary lag.
There was a problem hiding this comment.
waitForLatestTargetTable still hard-fails after max_attempts = 10 (about 6.5s total with the current backoff) and throws TABLE_UUID_MISMATCH.
This path is now used by both SYSTEM WAIT VIEW and dependency pre-sync via syncForDependentRefresh, so transient replication/catalog lag can still become user-visible refresh exceptions even when the expected table appears shortly after.
Please avoid a fixed short timeout here (or make it configurable with a conservative default and keep waiting by default).
There was a problem hiding this comment.
Still seeing this as unresolved in the current head.
waitForLatestTargetTable still hard-fails after max_attempts = 10 (~6.5s total) and throws TABLE_UUID_MISMATCH (src/Storages/MaterializedView/RefreshTask.cpp, around lines 569-609).
That fixed short window turns transient replication/catalog lag into user-visible failures in both paths that now use this helper: SYSTEM WAIT VIEW and dependency pre-sync for non-APPEND views (syncForDependentRefresh). Lag above a few seconds is realistic during replica restart/recovery or Keeper reconnect, so this can fail flows that would otherwise converge.
Please remove the hard short cap (or make it configurable with a conservative default that keeps waiting by default).
There was a problem hiding this comment.
Still seeing this as unresolved in the current head.
waitForLatestTargetTable keeps a fixed max_attempts = 10 with exponential backoff (src/Storages/MaterializedView/RefreshTask.cpp, around lines 569-610), so it throws TABLE_UUID_MISMATCH after about 6.5s.
That is too short for realistic replicated metadata/table propagation under lag/recovery, and this helper is used in both SYSTEM WAIT VIEW and dependency pre-sync (syncForDependentRefresh for non-APPEND). So transient lag is still converted into user-visible failures even when convergence would happen shortly after.
Please avoid a hard short cap here (or make it configurable with a conservative default that waits by default).
There was a problem hiding this comment.
This still looks unresolved in current HEAD.
waitForLatestTargetTable keeps a fixed max_attempts = 10 with backoff capped at 1s, so this path throws TABLE_UUID_MISMATCH after roughly 6.5s.
That bounded wait is now on both user-visible paths:
SYSTEM WAIT VIEW(wait->waitForLatestTargetTable)- dependency pre-sync for non-
APPENDviews (syncForDependentRefresh->waitForLatestTargetTable)
On replicated catalogs, metadata/table visibility can legitimately exceed that window during replica restart/recovery or Keeper reconnect. In those cases this converts transient lag into refresh exceptions even though the expected table appears shortly after.
Please avoid a fixed short cap here (or make it configurable with a conservative default that keeps waiting by default), so dependency-triggered refresh and SYSTEM WAIT VIEW do not fail on temporary lag.
|
CI has 16 different test failures unrelated to this PR. |
|
The one in FunctionsStressTest was already fixed in #104858 |
|
This was fixed by #105146. Let's update the branch. |
`aspell-dict.txt` was deleted in master along with the `aspell` and `codespell` style checks. Removing the file here so the PR can merge cleanly without a modify/delete conflict.
| "Time when the latest refresh attempt finished (if known) or started (if unknown or still running). NULL if no refresh attempts happened since server startup or table creation."}, | ||
| {"last_refresh_replica", std::make_shared<DataTypeString>(), "If coordination is enabled, name of the replica that made the current (if running) or previous (if not running) refresh attempt."}, | ||
| {"next_refresh_time", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeDateTime>()), "Time at which the next refresh is scheduled to start, if status = Scheduled."}, | ||
| {"next_refresh_time", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeDateTime>()), "Time at which the next refresh is scheduled to start. NULL if the next refresh time is not currently known, e.g. when waiting for dependencies (status `WaitingForDependencies` or `MissingDependencies`)."}, |
There was a problem hiding this comment.
The new description says next_refresh_time is NULL for MissingDependencies, but current behavior (and 02932_refreshable_materialized_views_3.reference) shows MissingDependencies can still have a concrete next_refresh_time (for REFRESH EVERY ... DEPENDS ON ...). Could we relax the wording so it doesn't promise NULL for all MissingDependencies cases?
LLVM Coverage Report
Changed lines: 94.68% (534/564) | lost baseline coverage: 16 line(s) · Uncovered code |
|
Hi @al13n321 @nikitamikhaylov — a quick suggestion to help reviewers. Description (currently empty): Ignore this if intentional. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
REFRESH DEPENDS ONto trigger refreshes on another RMV's refreshes instead of time-based schedule. (REFRESH EVERY ... DEPENDS ONalready existed, but couldn't be used reliably for this use case.) See CREATE MATERIALIZED VIEW documentation.From documentation:
Using DEPENDS ON for consistent propagation latency {#using-depends-on-for-consistent-propagation-latency}
If both views use
REFRESH EVERYwith the same period, the dependency applies in each timeslot.E.g. suppose views X and Y both use
REFRESH EVERY 1 HOUR, and Y reads from X's output table. Without dependencies, Y would usually see X's data from previous hour's refresh. WithDEPENDS ON X, Y's 11:00 refresh will start only after the X's 11:00 refresh completes.Both dependency and dependent may independently skip timeslots if refreshes run for longer than the refresh period. There's no guarantee that the dependent refreshes exactly once for each dependency refresh.
Using DEPENDS ON for batched stream processing {#using-depends-on-for-batched-stream-processing}
If
REFRESH EVERYis not used, the dependent view X refreshes if all its dependencies refreshed at least once since X's last refresh.REFRESH AFTER Tadds a delay: the dependent will start refresh T time after the dependency completes a refresh.Circular dependencies are allowed and useful. Consider this graph of refreshable materialized views:
Complete example:
Longer chains work as well.
This only works well when refresh coordination is enabled, i.e. the views are in Replicated or Shared database. Without coordination, server restart breaks the cycle, requiring a manual
SYSTEM REFRESH VIEWafter each restart rather than once after creating the views.Version info
26.6.1.170