Skip to content

Commit c8fee01

Browse files
committed
Keep the minRev between syncWatchers loops
Signed-off-by: Marek Siarkowicz <[email protected]>
1 parent b038739 commit c8fee01

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

server/storage/mvcc/watchable_store.go

+12-3
Original file line numberDiff line numberDiff line change
@@ -357,12 +357,21 @@ func (s *watchableStore) syncWatchers(evs []mvccpb.Event) (int, []mvccpb.Event)
357357
curRev := s.store.currentRev
358358
compactionRev := s.store.compactMainRev
359359

360-
wg, minRev := s.unsynced.choose(maxWatchersPerSync, curRev, compactionRev)
360+
minRev := s.unsynced.chooseAll(curRev, compactionRev)
361+
for _, batch := range s.victims {
362+
for w, b := range batch {
363+
watcherRev := max(w.minRev, b.moreRev)
364+
if len(b.evs) > 0 {
365+
watcherRev = max(watcherRev, b.evs[len(b.evs)-1].Kv.ModRevision)
366+
}
367+
minRev = min(minRev, watcherRev)
368+
}
369+
}
361370
evs = rangeEventsWithReuse(s.store.lg, s.store.b, evs, minRev, curRev+1)
362371

363372
victims := make(watcherBatch)
364-
wb := newWatcherBatch(wg, evs)
365-
for w := range wg.watchers {
373+
wb := newWatcherBatch(&s.unsynced, evs)
374+
for w := range s.unsynced.watchers {
366375
if w.minRev < compactionRev {
367376
// Skip the watcher that failed to send compacted watch response due to w.ch is full.
368377
// Next retry of syncWatchers would try to resend the compacted watch response to w.ch

0 commit comments

Comments
 (0)