From b15c57a5d46e2ec902808d581cf705b0b192fd74 Mon Sep 17 00:00:00 2001 From: ekexium Date: Wed, 12 Feb 2025 16:14:23 +0800 Subject: [PATCH] comment: explain the sequence number and data race Signed-off-by: ekexium --- internal/unionstore/art/art.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/unionstore/art/art.go b/internal/unionstore/art/art.go index dccfc50064..734bcc1a1c 100644 --- a/internal/unionstore/art/art.go +++ b/internal/unionstore/art/art.go @@ -54,6 +54,9 @@ type ART struct { missCount atomic.Uint64 // The counter of every write operation, used to invalidate iterators that were created before the write operation. + // The purpose of the counter is to check interleaving of write and read operations (via iterator). + // It does not protect against data race. If it happens, there must be a bug in the caller code. + // invariant: no concurrent access to it WriteSeqNo int // Increased by 1 when an operation that may affect the content returned by "snapshot" (i.e. stage[0]) happens. // It's used to invalidate snapshot iterators.