mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #6704 from heyitsanthony/proxy-broadcast-race
grpcproxy: fix race on watcher revision
This commit is contained in:
commit
06e2ce116c
@ -68,10 +68,14 @@ func (wg *watcherGroup) broadcast(wr clientv3.WatchResponse) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add adds the watcher into the group with given ID.
|
// add adds the watcher into the group with given ID.
|
||||||
// The current revision of the watcherGroup is returned.
|
// The current revision of the watcherGroup is returned or -1
|
||||||
|
// if the watcher is at a revision prior to the watcher group.
|
||||||
func (wg *watcherGroup) add(rid receiverID, w watcher) int64 {
|
func (wg *watcherGroup) add(rid receiverID, w watcher) int64 {
|
||||||
wg.mu.Lock()
|
wg.mu.Lock()
|
||||||
defer wg.mu.Unlock()
|
defer wg.mu.Unlock()
|
||||||
|
if wg.rev > w.rev {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
wg.receivers[rid] = w
|
wg.receivers[rid] = w
|
||||||
return wg.rev
|
return wg.rev
|
||||||
}
|
}
|
||||||
|
@ -102,11 +102,7 @@ func (wgs *watchergroups) maybeJoinWatcherSingle(rid receiverID, ws watcherSingl
|
|||||||
|
|
||||||
group, ok := wgs.groups[ws.w.wr]
|
group, ok := wgs.groups[ws.w.wr]
|
||||||
if ok {
|
if ok {
|
||||||
if ws.w.rev >= group.rev {
|
return group.add(receiverID{streamID: ws.sws.id, watcherID: ws.w.id}, ws.w) != -1
|
||||||
group.add(receiverID{streamID: ws.sws.id, watcherID: ws.w.id}, ws.w)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ws.canPromote() {
|
if ws.canPromote() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user