From fb9f5ce6f47c4eb28e016ddd852e2a7428e7d8a6 Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Mon, 22 Jul 2024 16:14:25 -0700 Subject: [PATCH] Update InternalVersionT::zero in addWrite call There can be other conflict sets in the same thread --- ConflictSet.cpp | 5 +++++ test_conflict_set.py | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 23fbf22..1f0195d 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -3177,6 +3177,11 @@ struct __attribute__((visibility("hidden"))) ConflictSet::Impl { } void addWrites(const WriteRange *writes, int count, int64_t writeVersion) { + // There could be other conflict sets in the same thread. We need + // InternalVersionT::zero to be correct for this conflict set for the + // lifetime of the current call frame. + InternalVersionT::zero = oldestVersion; + assert(writeVersion >= newestVersionFullPrecision); if (writeVersion > newestVersionFullPrecision + kNominalVersionWindow) { diff --git a/test_conflict_set.py b/test_conflict_set.py index ea046ee..23d79de 100644 --- a/test_conflict_set.py +++ b/test_conflict_set.py @@ -56,6 +56,20 @@ def test_conflict_set(): assert cs.check(read(0, key), read(1, key)) == [Result.TOO_OLD, Result.COMMIT] +def test_update_zero(): + with DebugConflictSet() as cs1: + with DebugConflictSet() as cs2: + cs1.addWrites(2, write(b"")) + cs1.setOldestVersion(2) + # "zero" is now 2 + + # make a Node48 + for i in range(256 - 17, 256): + cs2.addWrites(int(1), write(bytes([i]))) + # Scan until first point write + cs2.check(read(0, b"\x00", bytes([256 - 17]))) + + def test_inner_full_words(): with DebugConflictSet() as cs: cs.addWrites(1, write(b"\x3f\x61"), write(b"\x81\x61"))