Skip to content

Conversation

@martykulma
Copy link
Contributor

In the case of an ALTER SINK, don't snapshot if the sink upper has progressed beyond the as_of.

Motivation

fixes: https://github.com/MaterializeInc/database-issues/issues/9998

Checklist

  • This PR has adequate test coverage / QA involvement has been duly considered. (trigger-ci for additional test/nightly runs)
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • If this PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).
  • If this PR includes major user-facing behavior changes, I have pinged the relevant PM to schedule a changelog post.

@martykulma martykulma force-pushed the maz-no-snapshot-alter-sink branch from b37b565 to 154b7ab Compare December 22, 2025 19:18
@martykulma martykulma marked this pull request as ready for review December 23, 2025 01:11
@martykulma martykulma requested a review from a team as a code owner December 23, 2025 01:11
Copy link
Contributor

@patrickwwbutler patrickwwbutler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic seems fine to me, but I'm not well positioned to comment on the actual business repercussions of this change, so maybe worth getting another pair of eyes on it?


// For `ALTER SINK`, the snapshot should only occur if the sink has not made any progress.
// This prevents unnecessary decoding in the sink.
let alter_sink_snapshot = with_snapshot && !PartialOrder::less_than(&as_of, write_frontier);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newbie question: would LEQ instead of strict less_than not be right here? Is it possible for the as_of and write_frontier to be exactly equal? In that case is it possible that there is actually progress being made?

Copy link
Contributor Author

@martykulma martykulma Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The as_of is where we are reading from, and the upper is where the next write will happen. If the write frontier hasn't progressed strictly beyond the as_of, it would mean that nothing has been written (or we are not done writing).

For a simple example, consider the case where as_of is the minimum, e.g. [0], and the upper is also the minimum [0]. In this case, I need to write the snapshot, which happens at [0], and the upper can progress (lets say it is now [1]). At this point, we know that all data associated with times less than, but not equal to, [1] are written.

@martykulma martykulma requested a review from a team as a code owner December 23, 2025 22:45
@martykulma martykulma merged commit d572e50 into MaterializeInc:main Dec 23, 2025
131 checks passed
@bkirwi
Copy link
Contributor

bkirwi commented Dec 24, 2025

Good find and good fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants