You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "mrutunjay-kinagi (via GitHub)" <gi...@apache.org> on 2026/02/17 16:32:55 UTC

[PR] fix(table): validate snapshot timestamp drift on add snapshot [iceberg-python]

mrutunjay-kinagi opened a new pull request, #3062:
URL: https://github.com/apache/iceberg-python/pull/3062

   <!-- Closes #2938 -->
   
   # Rationale for this change
   Align snapshot timestamp validation with other Iceberg implementations by rejecting snapshots that drift backwards by more than one minute.
   
   The new guard in `AddSnapshotUpdate` checks:
   - snapshot timestamp vs latest `snapshot_log` entry
   - snapshot timestamp vs table `last_updated_ms`
   
   Both checks allow up to 60 seconds of clock skew tolerance.
   
   ## Are these changes tested?
   Yes.
   - Added `test_update_metadata_add_snapshot_rejects_old_timestamp_vs_snapshot_log`.
   - Added `test_update_metadata_add_snapshot_rejects_old_timestamp_vs_last_updated`.
   - Verified with targeted pytest run.
   
   ## Are there any user-facing changes?
   No API changes.
   - Invalid commit metadata now fails fast with explicit `ValueError` when timestamp drift exceeds tolerance.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix(table): validate snapshot timestamp drift on add snapshot [iceberg-python]

Posted by "mrutunjay-kinagi (via GitHub)" <gi...@apache.org>.
mrutunjay-kinagi commented on PR #3062:
URL: https://github.com/apache/iceberg-python/pull/3062#issuecomment-3921050524

   Here are the references we aligned with: Java enforces the tolerance inside  constructor (check the precondition around ) and Rust’s  enforces the same for . Both reject snapshot timestamps more than one minute behind the latest log entry. The new guard mirrors those checks so PyIceberg behaves the same way.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix(table): validate snapshot timestamp drift on add snapshot [iceberg-python]

Posted by "mrutunjay-kinagi (via GitHub)" <gi...@apache.org>.
mrutunjay-kinagi commented on PR #3062:
URL: https://github.com/apache/iceberg-python/pull/3062#issuecomment-3920803979

   Clarification on my previous comment (formatting issue):
   
   The guard is intended to prevent adding snapshots that are significantly older than the table timeline, specifically older than `last_updated_ms` or the latest `snapshot_log` entry by more than 60 seconds.
   
   This follows the same tolerance approach used in Java/Rust and keeps small clock skew allowed while rejecting larger backward drift.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix(table): validate snapshot timestamp drift on add snapshot [iceberg-python]

Posted by "mrutunjay-kinagi (via GitHub)" <gi...@apache.org>.
mrutunjay-kinagi commented on PR #3062:
URL: https://github.com/apache/iceberg-python/pull/3062#issuecomment-3920803303

   @Fokko Thanks for the review. The use case here is handling malformed/clock-skewed commit metadata safely and aligning behavior with Java/Rust, which already apply a 1-minute backward-drift tolerance for snapshot timestamps.\n\nWithout this guard, a client can add a snapshot timestamp that is significantly older than current table metadata ( / latest ), which can make timeline semantics inconsistent for timestamp-based operations.\n\nThis change keeps the same 60s tolerance and only rejects larger backward drift; small skew remains allowed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix(table): validate snapshot timestamp drift on add snapshot [iceberg-python]

Posted by "kevinjqliu (via GitHub)" <gi...@apache.org>.
kevinjqliu commented on PR #3062:
URL: https://github.com/apache/iceberg-python/pull/3062#issuecomment-3920964942

   > This follows the same tolerance approach used in Java/Rust and keeps small clock skew allowed while rejecting larger backward drift.
   
   could you point to the java/rust references? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix(table): validate snapshot timestamp drift on add snapshot [iceberg-python]

Posted by "mrutunjay-kinagi (via GitHub)" <gi...@apache.org>.
mrutunjay-kinagi commented on code in PR #3062:
URL: https://github.com/apache/iceberg-python/pull/3062#discussion_r2822319715


##########
pyiceberg/table/update/__init__.py:
##########
@@ -442,6 +443,18 @@ def _(update: AddSnapshotUpdate, base_metadata: TableMetadata, context: _TableMe
             f"Cannot add snapshot with sequence number {update.snapshot.sequence_number} "
             f"older than last sequence number {base_metadata.last_sequence_number}"
         )
+    elif (
+        base_metadata.snapshot_log and update.snapshot.timestamp_ms - base_metadata.snapshot_log[-1].timestamp_ms < -ONE_MINUTE_MS
+    ):
+        raise ValueError(

Review Comment:
   Good point. I kept `ValueError` for consistency with the existing validation branches in this same method (sequence/row-id checks all currently raise `ValueError`). If you prefer, I can switch this validation path to `CommitFailedException` in a follow-up commit.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix(table): validate snapshot timestamp drift on add snapshot [iceberg-python]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #3062:
URL: https://github.com/apache/iceberg-python/pull/3062#issuecomment-4105012900

   This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that's incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix(table): validate snapshot timestamp drift on add snapshot [iceberg-python]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #3062:
URL: https://github.com/apache/iceberg-python/pull/3062#issuecomment-4426303301

   This pull request has been closed due to lack of activity. This is not a judgement on the merit of the PR in any way. It is just a way of keeping the PR queue manageable. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix(table): validate snapshot timestamp drift on add snapshot [iceberg-python]

Posted by "mrutunjay-kinagi (via GitHub)" <gi...@apache.org>.
mrutunjay-kinagi commented on PR #3062:
URL: https://github.com/apache/iceberg-python/pull/3062#issuecomment-3921043942

   Reposting cleanly: the guard maintains the same exception type as the surrounding validation branches, so I kept it as `ValueError` for consistency. If you’d prefer `CommitFailedException` later, happy to follow up.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix(table): validate snapshot timestamp drift on add snapshot [iceberg-python]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on PR #3062:
URL: https://github.com/apache/iceberg-python/pull/3062#issuecomment-3924863440

   Hey @mrutunjay-kinagi Looking at the code:
   
   https://github.com/apache/iceberg/blame/d714576c7d53300e4b38d5ee27743dedbb153ace/core/src/main/java/org/apache/iceberg/TableMetadata.java#L360-L377
   
   The first loop will ensure that the snapshot log entries are sorted when parsing the JSON. The second checks that the last snapshot entry is not ahead of the lastUpdatedMillis. If we want to add this to PyIceberg, I think a better place is to do this when constructing the Metadata: https://github.com/apache/iceberg-python/blob/main/pyiceberg/table/metadata.py Similar to what Java/Rust are doing. Thoughts?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix(table): validate snapshot timestamp drift on add snapshot [iceberg-python]

Posted by "mrutunjay-kinagi (via GitHub)" <gi...@apache.org>.
mrutunjay-kinagi commented on PR #3062:
URL: https://github.com/apache/iceberg-python/pull/3062#issuecomment-3921035971

   The existing validation branches inside  are raising , so for symmetry I left this guard as  as well. If you’d prefer switching to  later that’s easy to follow up on but I’d keep the current behavior for consistency.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix(table): validate snapshot timestamp drift on add snapshot [iceberg-python]

Posted by "mrutunjay-kinagi (via GitHub)" <gi...@apache.org>.
mrutunjay-kinagi commented on PR #3062:
URL: https://github.com/apache/iceberg-python/pull/3062#issuecomment-4187041441

   @Fokko @kevinjqliu  Requesting review.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix(table): validate snapshot timestamp drift on add snapshot [iceberg-python]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #3062:
URL: https://github.com/apache/iceberg-python/pull/3062#issuecomment-4375655533

   This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that's incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix(table): validate snapshot timestamp drift on add snapshot [iceberg-python]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #3062: fix(table): validate snapshot timestamp drift on add snapshot
URL: https://github.com/apache/iceberg-python/pull/3062


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix(table): validate snapshot timestamp drift on add snapshot [iceberg-python]

Posted by "mrutunjay-kinagi (via GitHub)" <gi...@apache.org>.
mrutunjay-kinagi commented on PR #3062:
URL: https://github.com/apache/iceberg-python/pull/3062#issuecomment-4110463291

   @Fokko, please take a look if this is still relevant.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix(table): validate snapshot timestamp drift on add snapshot [iceberg-python]

Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on code in PR #3062:
URL: https://github.com/apache/iceberg-python/pull/3062#discussion_r2822204042


##########
pyiceberg/table/update/__init__.py:
##########
@@ -442,6 +443,18 @@ def _(update: AddSnapshotUpdate, base_metadata: TableMetadata, context: _TableMe
             f"Cannot add snapshot with sequence number {update.snapshot.sequence_number} "
             f"older than last sequence number {base_metadata.last_sequence_number}"
         )
+    elif (
+        base_metadata.snapshot_log and update.snapshot.timestamp_ms - base_metadata.snapshot_log[-1].timestamp_ms < -ONE_MINUTE_MS
+    ):
+        raise ValueError(

Review Comment:
   Maybe `CommitFailedException`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix(table): validate snapshot timestamp drift on add snapshot [iceberg-python]

Posted by "mrutunjay-kinagi (via GitHub)" <gi...@apache.org>.
mrutunjay-kinagi commented on PR #3062:
URL: https://github.com/apache/iceberg-python/pull/3062#issuecomment-3924977589

   @Fokko Reposting cleanly (previous comment had shell formatting issues).
   
   Thanks, good suggestion. I pushed a follow-up commit that adds metadata-level timestamp validation in `pyiceberg/table/metadata.py` so we validate on metadata construction as well:
   
   - `snapshot-log` entries must remain sorted (with the same 1-minute skew tolerance used in Java)
   - `last-updated-ms` cannot be more than 1 minute behind the latest snapshot-log entry
   
   I also added parser-level tests in `tests/table/test_metadata.py` for both checks.
   
   I kept the existing `AddSnapshotUpdate` guard too, because that check depends on prior metadata state during update application (metadata parsing alone cannot fully recover that context).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix(table): validate snapshot timestamp drift on add snapshot [iceberg-python]

Posted by "mrutunjay-kinagi (via GitHub)" <gi...@apache.org>.
mrutunjay-kinagi commented on PR #3062:
URL: https://github.com/apache/iceberg-python/pull/3062#issuecomment-3924977228

   @Fokko Thanks, good suggestion. I pushed a follow-up commit that adds metadata-level timestamp validation in  so we validate on metadata construction as well:\n\n- snapshot-log entries must remain sorted (with the same 1-minute skew tolerance used in Java)\n-  cannot be more than 1 minute behind the latest snapshot-log entry\n\nI also added parser-level tests in  for both checks.\n\nI kept the existing  guard too, because that check depends on the previous metadata state during update application (which metadata parsing alone can’t fully recover).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org