1fanwang commented on code in PR #3760:
URL: https://github.com/apache/iceberg-python/pull/3760#discussion_r4545277024


##########
pyiceberg/table/update/snapshot.py:
##########
@@ -1261,9 +1265,18 @@ def _commit(self) -> UpdatesAndRequirements:
             Tuple of updates and requirements to be committed,
             as required by the calling parent apply functions.
         """
-        # Remove any protected snapshot IDs from the set to expire, just in 
case
+        # Resolved here rather than in older_than() so that snapshots released 
by
+        # remove_expired_refs() are expirable no matter which order the two 
were called in.
         protected_ids = self._get_protected_snapshot_ids()
+        if self._expire_older_than_ms is not None:
+            for snapshot in self._transaction.table_metadata.snapshots:
+                if snapshot.timestamp_ms < self._expire_older_than_ms and 
snapshot.snapshot_id not in protected_ids:
+                    self._snapshot_ids_to_expire.add(snapshot.snapshot_id)
+
+        # Remove any protected snapshot IDs from the set to expire, just in 
case
         self._snapshot_ids_to_expire -= protected_ids
+        for ref_name in self._ref_names_to_remove:
+            self._updates += (RemoveSnapshotRefUpdate(ref_name=ref_name),)

Review Comment:
   Done in 
https://github.com/apache/iceberg-python/commit/b1bd6ed46ef3849a88f16bcc84c71e0f7309dc89.
 Each removed ref now asserts the snapshot it pointed at when it was judged 
expired, so a branch that advanced meanwhile fails the 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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to