Skip to content

Commit c40fead

Browse files
committed
Fix sending watch progress with revision=0
Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
1 parent bf071b4 commit c40fead

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

pkg/server/watch.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,18 @@ func (w *watcher) Start(ctx context.Context, r *etcdserverpb.WatchCreateRequest)
154154
inner = false
155155
}
156156
}
157+
// get max revision from collected events
158+
if len(events) > 0 {
159+
revision = events[len(events)-1].KV.ModRevision
160+
}
157161
case revision = <-progressCh:
158162
// have been requested to send progress with no events
159163
}
160164

161-
// get max revision from collected events
162-
if len(events) > 0 {
163-
revision = events[len(events)-1].KV.ModRevision
164-
}
165-
166-
// send response. note that there are no events if this is a progress response.
167-
if len(events) == 0 || revision >= startRevision {
165+
// send response. note that there are no events if this is a progress response -
166+
// but revision 0 is also sent on the progress channel to check if this
167+
// reader has synced or not, so we must not send with revision 0.
168+
if revision != 0 && (len(events) == 0 || revision >= startRevision) {
168169
wr := &etcdserverpb.WatchResponse{
169170
Header: txnHeader(revision),
170171
WatchId: id,

0 commit comments

Comments
 (0)