From 55c16df99702cacc387433c4d7d9bdb8da04262c Mon Sep 17 00:00:00 2001 From: "leoyang.yl" Date: Thu, 25 Nov 2021 20:11:05 +0800 Subject: [PATCH] fix runlock bug --- server/mvcc/watchable_store.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/mvcc/watchable_store.go b/server/mvcc/watchable_store.go index 3c7edb33371..0e5be8ecb26 100644 --- a/server/mvcc/watchable_store.go +++ b/server/mvcc/watchable_store.go @@ -355,8 +355,11 @@ func (s *watchableStore) syncWatchers() int { tx := s.store.b.ReadTx() tx.RLock() revs, vs := tx.UnsafeRange(buckets.Key, minBytes, maxBytes, 0) - tx.RUnlock() evs := kvsToEvents(s.store.lg, wg, revs, vs) + // Must unlock after kvsToEvents, because vs (come from boltdb memory) is not deep copy. + // We can only unlock after Unmarshal, which will do deep copy. + // Otherwise we will trigger SIGSEGV during boltdb re-mmap. + tx.RUnlock() var victims watcherBatch wb := newWatcherBatch(wg, evs)