Skip to content

Commit

Permalink
clientv3: fix race on watch initial revision
Browse files Browse the repository at this point in the history
The initial revision was being updated in the substream goroutine defer;
this was racing with the resume path fetching the initial revision when
the substream closes during resume. Instead, update the initial revision
whenever the substream processes a new watch response. Since the substream
cannot receive a watch response while it is resuming, the write to the
initial revision is ordered to always happen after the resume read.

Fixes #6586
  • Loading branch information
Anthony Romano committed Oct 5, 2016
1 parent 98897b7 commit 06d5cf2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion clientv3/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,6 @@ func (w *watchGrpcStream) serveSubstream(ws *watcherStream, resumec chan struct{
if !resuming {
ws.closing = true
}
ws.initReq.rev = nextRev
close(ws.donec)
if !resuming {
w.closingc <- ws
Expand Down Expand Up @@ -619,6 +618,7 @@ func (w *watchGrpcStream) serveSubstream(ws *watcherStream, resumec chan struct{
if len(wr.Events) > 0 {
nextRev = wr.Events[len(wr.Events)-1].Kv.ModRevision + 1
}
ws.initReq.rev = nextRev
case <-ws.initReq.ctx.Done():
return
case <-resumec:
Expand Down

0 comments on commit 06d5cf2

Please sign in to comment.