From fd7e951fba00cb3fd44165e1bd8d3dd4f498b253 Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Fri, 21 Apr 2017 00:28:39 -0700 Subject: [PATCH] clientv3: only update initReq.rev == 0 with creation watch revision Always updating the initReq.rev on watch create will resume from the wrong revision if initReq is ever nonzero. --- clientv3/watch.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/clientv3/watch.go b/clientv3/watch.go index 7847b03b321c..215d4ab1e833 100644 --- a/clientv3/watch.go +++ b/clientv3/watch.go @@ -615,11 +615,17 @@ func (w *watchGrpcStream) serveSubstream(ws *watcherStream, resumec chan struct{ // send first creation event only if requested if ws.initReq.createdNotify { ws.outc <- *wr + if ws.initReq.rev == 0 { + // current revision of store + nextRev = wr.Header.Revision + } } } + } else { + // current progress of watch; <= store revision + nextRev = wr.Header.Revision } - nextRev = wr.Header.Revision if len(wr.Events) > 0 { nextRev = wr.Events[len(wr.Events)-1].Kv.ModRevision + 1 }