Skip to content

Commit 621b43f

Browse files
committed
Fix thread safety in ExpireSnapshots by initializing instance-level attributes
1 parent 52d810e commit 621b43f

2 files changed

Lines changed: 490 additions & 5 deletions

File tree

pyiceberg/table/update/snapshot.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -924,9 +924,12 @@ class ExpireSnapshots(UpdateTableMetadata["ExpireSnapshots"]):
924924
Pending changes are applied on commit.
925925
"""
926926

927-
_snapshot_ids_to_expire: Set[int] = set()
928-
_updates: Tuple[TableUpdate, ...] = ()
929-
_requirements: Tuple[TableRequirement, ...] = ()
927+
def __init__(self, transaction: Transaction) -> None:
928+
super().__init__(transaction)
929+
# Initialize instance-level attributes to avoid sharing state between instances
930+
self._snapshot_ids_to_expire: Set[int] = set()
931+
self._updates: Tuple[TableUpdate, ...] = ()
932+
self._requirements: Tuple[TableRequirement, ...] = ()
930933

931934
def _commit(self) -> UpdatesAndRequirements:
932935
"""

0 commit comments

Comments
 (0)