Skip to content

Commit

Permalink
mvcc: no need to hold tx lock when converting kvs to watch events (#1…
Browse files Browse the repository at this point in the history
…1701)

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.
  • Loading branch information
mlmhl committed Mar 20, 2020
1 parent 72526ce commit 0eee733
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mvcc/watchable_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0eee733

Please sign in to comment.