mvcc: update minRev when watcher stays synced

Problem: during restore in watchableStore.Restore, synced watchers are moved to unsynced.
minRev will be behind since it's not updated when watcher stays synced.

Solution: update minRev

fixes: https://github.com/etcd-io/etcd/issues/15271
Signed-off-by: Bogdan Kanivets <bkanivets@apple.com>
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
This commit is contained in:
Bogdan Kanivets
2023-03-09 14:11:37 -08:00
committed by Marek Siarkowicz
parent 930a450a55
commit dafdaaedf2

View File

@@ -447,7 +447,6 @@ func (s *watchableStore) notify(rev int64, evs []mvccpb.Event) {
pendingEventsGauge.Add(float64(len(eb.evs))) pendingEventsGauge.Add(float64(len(eb.evs)))
} else { } else {
// move slow watcher to victims // move slow watcher to victims
w.minRev = rev + 1
if victim == nil { if victim == nil {
victim = make(watcherBatch) victim = make(watcherBatch)
} }
@@ -456,6 +455,10 @@ func (s *watchableStore) notify(rev int64, evs []mvccpb.Event) {
s.synced.delete(w) s.synced.delete(w)
slowWatcherGauge.Inc() slowWatcherGauge.Inc()
} }
// always update minRev
// in case 'send' returns true and watcher stays synced, this is needed for Restore when all watchers become unsynced
// in case 'send' returns false, this is needed for syncWatchers
w.minRev = rev + 1
} }
s.addVictim(victim) s.addVictim(victim)
} }