From dafdaaedf2ef4e7ef5de2170a90f2477f02b71d9 Mon Sep 17 00:00:00 2001 From: Bogdan Kanivets Date: Thu, 9 Mar 2023 14:11:37 -0800 Subject: [PATCH] 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 Signed-off-by: Marek Siarkowicz --- 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 27a19fae6..3a9fd344c 100644 --- a/server/mvcc/watchable_store.go +++ b/server/mvcc/watchable_store.go @@ -447,7 +447,6 @@ func (s *watchableStore) notify(rev int64, evs []mvccpb.Event) { pendingEventsGauge.Add(float64(len(eb.evs))) } else { // move slow watcher to victims - w.minRev = rev + 1 if victim == nil { victim = make(watcherBatch) } @@ -456,6 +455,10 @@ func (s *watchableStore) notify(rev int64, evs []mvccpb.Event) { s.synced.delete(w) 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) }