Repository navigation
fix(update): keep snapshot timestamps strictly increasing - #1152
Merged
Merged
Conversation
The v4 spec requires a snapshot's timestamp-ms to be strictly greater than its parent's. SnapshotUpdate stamped new snapshots with the current time, so two commits in the same millisecond, or a commit on top of a parent from a clock running ahead, broke that rule. New snapshots now get max(now, parent.timestamp_ms + 1), where the parent is the head of the target branch. This matches Java's SnapshotProducer.snapshotTimestampMillis (apache/iceberg#16293) and, like Java, applies to every format version. Tests cover a first snapshot, back-to-back commits, a parent in the future, and a branch whose parent differs from main's head.
zhjwpku
approved these changes
Nov 21, 2026
zhjwpku
left a comment
Member
There was a problem hiding this comment.
Works for me. I guess this restriction won't cause any regressions in pre-v4.
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.
The v4 spec requires a snapshot's
timestamp-msto be strictly greater than its parent's.SnapshotUpdatestamped new snapshots with the current time, so two commits in the same millisecond, or a commit on top of a parent written by a clock running ahead, broke that rule. Those commits would fail once v4 writes and the matching validation (#1070) land.New snapshots now get
max(now, parent.timestamp_ms + 1), where the parent is the head of the target branch. This matches Java'sSnapshotProducer.snapshotTimestampMillisfrom apache/iceberg#16293 (apache/iceberg#16293) and, like Java, applies to every format version. Every snapshot producer, including a non-fast-forward cherry-pick, goes throughSnapshotUpdate::Apply, so this is the only place that needs the change.New
SnapshotTimestampTestcases:FirstSnapshotUsesCurrentTime: with no parent, the snapshot gets the current time.SuccessiveCommitsStrictlyIncrease: back-to-back commits on one branch get strictly increasing timestamps.FutureParentGetsParentPlusOne: with main's head one hour in the future, two commits get parent+1, then parent+2.UsesParentOnTargetBranch: a branch whose parent is in the past gets the current time, while main, whose head is in the future, gets parent+1.A parent in the future acts as a clock that hasn't caught up, so no clock injection point is needed.
Part of #1107.