Test the two-billion-version window in every implementation
CI / test (arm64, -DCMAKE_BUILD_TYPE=Debug -DMSAN_TOOLCHAIN_PATH=/opt/msan, 22, https://minio.weaselab.dev/public/aarch64/msan-toolchain-22.1.8.tar.zst, debug-arm64, ubuntu-latest-arm64) (pull_request) Successful in 4m6s
CI / release (arm64, , ubuntu-latest-arm64) (pull_request) Successful in 4m31s
CI / pre-commit (pull_request) Successful in 2m22s
CI / test (amd64, -DCMAKE_BUILD_TYPE=Debug -DMSAN_TOOLCHAIN_PATH=/opt/msan, 21, https://minio.weaselab.dev/public/x86_64/msan-toolchain-21.1.8.tar.zst, debug, ubuntu-latest-amd64) (pull_request) Successful in 4m10s
CI / test (amd64, -DCMAKE_CXX_FLAGS=-DUSE_64_BIT=1, 21, , 64-bit-versions, ubuntu-latest-amd64) (pull_request) Successful in 3m38s
CI / test (amd64, -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++, 21, , gcc, ubuntu-latest-amd64) (pull_request) Successful in 3m36s
CI / test (amd64, -DUSE_SIMD_FALLBACK=ON, 21, , simd-fallback, ubuntu-latest-amd64) (pull_request) Successful in 3m36s
CI / release (amd64, -DMSAN_TOOLCHAIN_PATH=/opt/msan, ubuntu-latest-amd64) (pull_request) Successful in 6m0s
CI / coverage (pull_request) Successful in 4m6s

test_two_billion_versions asserted nothing about the results, and hash_table
was never exercised across a version jump larger than two billion. Assert the
expected results and add test_two_billion_version_window, which checks the
window boundary (and the count == 0 case) for radix_tree, skip_list and
hash_table.
This commit is contained in:
weaselbot committed 2026-11-10 15:28:59 -05:00
1 parent 78a5e8a5d5
commit 2f4de127c0
1 file changed
+26 -2
+26 -2
View File
@@ -205,8 +205,32 @@ def test_internal_version_zero():
def test_two_billion_versions():
with DebugConflictSet() as cs:
cs.addWrites(int(2e9) + 1)
cs.check(read(0, b"\x00", b"\xff"))
cs.check(read(1, b"\x00", b"\xff"))
assert cs.check(read(0, b"\x00", b"\xff")) == [Result.TOO_OLD]
assert cs.check(read(1, b"\x00", b"\xff")) == [Result.COMMIT]
def test_two_billion_version_window():
# Regression test for issue #98: `addWrites` advances `newestVersion`, so a
# read whose readVersion fell more than two billion versions behind it is
# TooOld. `hash_table` used to discard writeVersion entirely, so it reported
# Conflict/Commit for reads far outside the version window.
window = 2 * 10**9
newest = 2**32
def probe(implementation, read_version, *writes):
with ConflictSet(0, build_dir=build_dir, implementation=implementation) as cs:
cs.addWrites(newest, *writes)
return cs.check(read(read_version, b"k"))[0]
for implementation in ("radix_tree", "skip_list", "hash_table"):
# The window advances even when addWrites added no writes at all.
assert probe(implementation, 0, write(b"k")) == Result.TOO_OLD
assert probe(implementation, 0) == Result.TOO_OLD
assert probe(implementation, newest - window - 1, write(b"k")) == Result.TOO_OLD
assert probe(implementation, newest - window - 1) == Result.TOO_OLD
# Exactly `window` versions behind newestVersion is still evaluable.
assert probe(implementation, newest - window, write(b"k")) == Result.CONFLICT
assert probe(implementation, newest - window) == Result.COMMIT
def test_positive_bytes():