mvcc: no need to hold tx lock when converting kvs to watch events (#11701)

Method `kvsToEvents` can take a long time if a large number of events need to be synchronized. However, this method does not access any shared resources, so it no need to hold the tx lock when executing. So we can move it outside to reduce lock holding time.
release-3.5
mlmhl 2020-03-20 12:01:36 +08:00 committed by GitHub
parent 72526cef00
commit 0eee733220
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -358,9 +358,9 @@ func (s *watchableStore) syncWatchers() int {
tx := s.store.b.ReadTx()
tx.RLock()
revs, vs := tx.UnsafeRange(keyBucketName, minBytes, maxBytes, 0)
tx.RUnlock()
var evs []mvccpb.Event
evs = kvsToEvents(s.store.lg, wg, revs, vs)
tx.RUnlock()
var victims watcherBatch
wb := newWatcherBatch(wg, evs)