persist: coalesce source frontier downgrades during hydration - #37313
Merged
Merged
Conversation
antiguru
marked this pull request as ready for review
June 26, 2026 11:33
def-
reviewed
Jun 27, 2026
Contributor
There was a problem hiding this comment.
Test changes lgtm, nightly triggered: https://buildkite.com/materialize/nightly/builds/16905 No other concerns Edit: Test failures seem unrelated
petrosagg
reviewed
Jul 2, 2026
While catching up to the shard upper observed at hydration time, the persist source withholds per-batch progress and forwards it in larger, byte-bounded steps. This turns a long historical replay from one progress round (and one downstream arrangement-maintenance pass) per persist batch into a handful of steps. Emitted parts keep their real timestamps, so only the frontier granularity changes, not the data. Gated by persist_source_hydration_frontier_coalesce_bytes (default 0 = disabled); tracking snaps back to per-batch once the source is live. This recreates the frontier-coalescing feature on the async persist source operator, without the underlying deasync refactor. The forward/coalesce decision is factored into should_forward_progress and covered by tests: test_frontier_coalesce_decision checks the round reduction directly, and test_shard_source_hydration_frontier_coalesce hydrates an index over 64 unmerged single-timestamp batches and asserts both coalescing on and off emit parts through the final timestamp without stalling. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rYj64cXLGKvkpiYdpwKgZ
The lint_test_flags check requires every dyncfg to be known to the test harnesses. Register persist_source_hydration_frontier_coalesce_bytes with valid byte values (0 = disabled, plus 1/16/128 MiB) in FlipFlagsAction and in get_variable_system_parameters. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rYj64cXLGKvkpiYdpwKgZ
- Add ReadHandle::shared_upper mirroring WriteHandle::shared_upper, and use it in shard_source instead of reaching into machine.applier internals. - Inline the trivial forward/coalesce decision at the call site and trim the surrounding commentary. The round-reduction test computes the same expression directly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015rYj64cXLGKvkpiYdpwKgZ
antiguru
force-pushed
the
claude/pr-recreation-main-tj71ah
branch
from
July 6, 2026 08:28
dd61581 to
572b75b
Compare
petrosagg
approved these changes
Jul 6, 2026
Member
Author
|
Thanks for the reviews! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Hydrating an index with retained history replays the source's whole batch
history. For a collection written at ~1/s whose batches stay unmerged (the
held-back
sinceblocks compaction), that is one progress round per persistbatch, and each round triggers an arrangement-maintenance pass on every
replica. Hundreds of thousands of rounds make hydration slow.
What this does
While catching up to the shard upper observed at hydration time, the persist
source withholds per-batch progress and forwards it in larger, byte-bounded
steps. This collapses a long historical replay from one progress round per
persist batch into a handful of steps. Emitted parts keep their real
timestamps, so only the frontier granularity changes, not the data. Once the
source reaches the hydration-time upper (it is live), tracking snaps back to
per-batch so consumers relying on tight frontier tracking, such as
persist_sink, are unaffected in steady state.Gated by the new dyncfg
persist_source_hydration_frontier_coalesce_bytes(default
0= disabled).Relationship to antiguru#180
This recreates the frontier-coalescing feature on the current async persist
source operator, without the underlying deasync refactor that the original
change was built on top of. In the async operator the "forward progress"
action is
cap_set.downgrade(...); coalescing holds that downgrade back whileparts continue to flow at their real timestamps. The forward/coalesce decision
is factored into
should_forward_progress.Tests
test_frontier_coalesce_decisionchecks the round reduction directly(disabled forwards once per batch; a budget larger than the replay forwards
once; a mid budget lands strictly between), independent of timely's progress
batching.
test_shard_source_hydration_frontier_coalescehydrates an index over 64unmerged single-timestamp batches (compaction disabled, mirroring a held-back
since) and asserts that coalescing on and off both emit parts through thefinal timestamp without stalling.
Generated by Claude Code