Skip to content

Commit 5a18502

Browse files
committed
Fix thread safety in ExpireSnapshots tests by ensuring isolated instances
1 parent e7d25f8 commit 5a18502

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

tests/table/test_expire_snapshots.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ def test_expire_snapshots_by_ids(table_v2: Table) -> None:
231231
def test_thread_safety_fix() -> None:
232232
"""Test that ExpireSnapshots instances have isolated state."""
233233
# Create two ExpireSnapshots instances
234-
expire1 = ExpireSnapshots(None)
235-
expire2 = ExpireSnapshots(None)
234+
expire1 = ExpireSnapshots(Mock())
235+
expire2 = ExpireSnapshots(Mock())
236236

237237
# Verify they have separate snapshot sets (this was the bug!)
238238
# Before fix: both would have the same id (shared class attribute)
@@ -255,14 +255,12 @@ def test_concurrent_operations() -> None:
255255
results: Dict[str, set[int]] = {"expire1_snapshots": set(), "expire2_snapshots": set()}
256256

257257
def worker1() -> None:
258-
transaction1 = Mock()
259-
expire1 = ExpireSnapshots(transaction1)
258+
expire1 = ExpireSnapshots(Mock())
260259
expire1._snapshot_ids_to_expire.update([1001, 1002, 1003])
261260
results["expire1_snapshots"] = expire1._snapshot_ids_to_expire.copy()
262261

263262
def worker2() -> None:
264-
transaction2 = Mock()
265-
expire2 = ExpireSnapshots(transaction2)
263+
expire2 = ExpireSnapshots(Mock())
266264
expire2._snapshot_ids_to_expire.update([2001, 2002, 2003])
267265
results["expire2_snapshots"] = expire2._snapshot_ids_to_expire.copy()
268266

0 commit comments

Comments
 (0)