From 0952db5af7b203ccb2e8ea42310e0783d2a54911 Mon Sep 17 00:00:00 2001 From: Seebs Date: Mon, 14 Dec 2020 11:18:13 -0600 Subject: [PATCH] Add (temporary, perhaps) locking on TestTx_CountRange On roaring, CountRange needs to have exclusive access to a fragment, but doesn't currently require a lock, because it's usually used from inside other already-locked things. --- tx_internal_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tx_internal_test.go b/tx_internal_test.go index 3cafba24a..a5da9cccd 100644 --- a/tx_internal_test.go +++ b/tx_internal_test.go @@ -81,6 +81,11 @@ func TestTx_CountRange(t *testing.T) { f, tx := requireCountRangeSampleData(t) defer f.Clean(t) defer tx.Rollback() + // CountRange accesses the fragment without locking. Normally we only + // call it from inside a fragment routine with locking. Otherwise, you + // can have a race condition with snapshots, for instance. + f.mu.Lock() + defer f.mu.Unlock() expected := uint64(0) j := uint64(0)