|
|
@@ -144,7 +144,6 @@ func (s *watchableStore) watch(key, end []byte, startRev int64, id WatchID, ch c
|
|
|
func (s *watchableStore) cancelWatcher(wa *watcher) {
|
|
|
for {
|
|
|
s.mu.Lock()
|
|
|
-
|
|
|
if s.unsynced.delete(wa) {
|
|
|
slowWatcherGauge.Dec()
|
|
|
break
|
|
|
@@ -152,6 +151,9 @@ func (s *watchableStore) cancelWatcher(wa *watcher) {
|
|
|
break
|
|
|
} else if wa.compacted {
|
|
|
break
|
|
|
+ } else if wa.ch == nil {
|
|
|
+ // already canceled (e.g., cancel/close race)
|
|
|
+ break
|
|
|
}
|
|
|
|
|
|
if !wa.victim {
|
|
|
@@ -177,6 +179,7 @@ func (s *watchableStore) cancelWatcher(wa *watcher) {
|
|
|
}
|
|
|
|
|
|
watcherGauge.Dec()
|
|
|
+ wa.ch = nil
|
|
|
s.mu.Unlock()
|
|
|
}
|
|
|
|
|
|
@@ -425,7 +428,6 @@ func (s *watchableStore) notify(rev int64, evs []mvccpb.Event) {
|
|
|
if eb.revs != 1 {
|
|
|
plog.Panicf("unexpected multiple revisions in notification")
|
|
|
}
|
|
|
-
|
|
|
if w.send(WatchResponse{WatchID: w.id, Events: eb.evs, Revision: rev}) {
|
|
|
pendingEventsGauge.Add(float64(len(eb.evs)))
|
|
|
} else {
|