mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
mvcc: move blocked unsynced watchers to victim list
This commit is contained in:
parent
5984e46364
commit
394ce5f3b8
@ -383,6 +383,7 @@ func (s *watchableStore) syncWatchers() {
|
|||||||
evs := kvsToEvents(wg, revs, vs)
|
evs := kvsToEvents(wg, revs, vs)
|
||||||
tx.Unlock()
|
tx.Unlock()
|
||||||
|
|
||||||
|
var victims watcherBatch
|
||||||
wb := newWatcherBatch(wg, evs)
|
wb := newWatcherBatch(wg, evs)
|
||||||
for w := range wg.watchers {
|
for w := range wg.watchers {
|
||||||
eb, ok := wb[w]
|
eb, ok := wb[w]
|
||||||
@ -394,23 +395,30 @@ func (s *watchableStore) syncWatchers() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
w.cur = curRev
|
||||||
|
isBlocked := false
|
||||||
select {
|
select {
|
||||||
case w.ch <- WatchResponse{WatchID: w.id, Events: eb.evs, Revision: curRev}:
|
case w.ch <- WatchResponse{WatchID: w.id, Events: eb.evs, Revision: curRev}:
|
||||||
pendingEventsGauge.Add(float64(len(eb.evs)))
|
pendingEventsGauge.Add(float64(len(eb.evs)))
|
||||||
default:
|
default:
|
||||||
// TODO: handle the full unsynced watchers.
|
if victims == nil {
|
||||||
// continue to process other watchers for now, the full ones
|
victims = make(watcherBatch)
|
||||||
// will be processed next time and hopefully it will not be full.
|
}
|
||||||
continue
|
isBlocked = true
|
||||||
}
|
}
|
||||||
if eb.moreRev != 0 {
|
|
||||||
w.cur = eb.moreRev
|
if isBlocked {
|
||||||
continue
|
victims[w] = eb
|
||||||
|
} else {
|
||||||
|
if eb.moreRev != 0 {
|
||||||
|
w.cur = eb.moreRev
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
s.synced.add(w)
|
||||||
}
|
}
|
||||||
w.cur = curRev
|
|
||||||
s.synced.add(w)
|
|
||||||
s.unsynced.delete(w)
|
s.unsynced.delete(w)
|
||||||
}
|
}
|
||||||
|
s.addVictim(victims)
|
||||||
|
|
||||||
vsz := 0
|
vsz := 0
|
||||||
for _, v := range s.victims {
|
for _, v := range s.victims {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user