From 6de11698623d4ecaa4956e936e15ee31f0711fab 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 --- server/storage/mvcc/watchable_store.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/storage/mvcc/watchable_store.go b/server/storage/mvcc/watchable_store.go index adf07f7755b..f0d056f286d 100644 --- a/server/storage/mvcc/watchable_store.go +++ b/server/storage/mvcc/watchable_store.go @@ -448,12 +448,15 @@ 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 w.victim = true victim[w] = eb 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) }