From 077dd74827b82ed07d9802b50518711ef14a0fa3 Mon Sep 17 00:00:00 2001 From: Ziheng Liu Date: Sun, 4 Aug 2019 16:37:17 -0700 Subject: [PATCH] mvcc: add a TODO in (*store).Hash, to warn against potential data race of currentRev and suggest feasible fix --- mvcc/kvstore.go | 1 + 1 file changed, 1 insertion(+) diff --git a/mvcc/kvstore.go b/mvcc/kvstore.go index bc9d3007e..49b2b9a5f 100644 --- a/mvcc/kvstore.go +++ b/mvcc/kvstore.go @@ -165,6 +165,7 @@ func (s *store) compactBarrier(ctx context.Context, ch chan struct{}) { } func (s *store) Hash() (hash uint32, revision int64, err error) { + // TODO: hash and revision could be inconsistent, one possible fix is to add s.revMu.RLock() at the beginning of function, which is costly start := time.Now() s.b.ForceCommit()