From 4025f365a9dad47e25e8d49b3e60358e480df662 Mon Sep 17 00:00:00 2001 From: Chao Chen Date: Thu, 7 Mar 2024 22:38:35 -0800 Subject: [PATCH] Fix slow watchers event loss after compaction Signed-off-by: Chao Chen --- server/storage/mvcc/watchable_store.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/storage/mvcc/watchable_store.go b/server/storage/mvcc/watchable_store.go index ae5c551fdfe6..33114fc51aaa 100644 --- a/server/storage/mvcc/watchable_store.go +++ b/server/storage/mvcc/watchable_store.go @@ -370,6 +370,12 @@ func (s *watchableStore) syncWatchers() int { victims := make(watcherBatch) wb := newWatcherBatch(wg, evs) for w := range wg.watchers { + if w.minRev < compactionRev { + // skip the watcher that failed to send compacted watch response due to w.ch is full + // next retry of syncWatchers would try to resend the compacted watch response to w.ch + // TODO prioritize sending compacted watch response over other watch responses with events. + continue + } w.minRev = curRev + 1 eb, ok := wb[w]