Skip to content

Commit

Permalink
Merge pull request #8283 from heyitsanthony/cancel-compact-rpc
Browse files Browse the repository at this point in the history
v3rpc: set Canceled=true on compacted watch
  • Loading branch information
Anthony Romano authored Jul 26, 2017
2 parents 8b11771 + 9581f76 commit 16943f0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions clientv3/integration/watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,9 @@ func TestWatchCompactRevision(t *testing.T) {
if wresp.Err() != rpctypes.ErrCompacted {
t.Fatalf("wresp.Err() expected %v, but got %v", rpctypes.ErrCompacted, wresp.Err())
}
if !wresp.Canceled {
t.Fatalf("wresp.Canceled expected true, got %+v", wresp)
}

// ensure the channel is closed
if wresp, ok = <-wch; ok {
Expand Down
2 changes: 1 addition & 1 deletion clientv3/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ func (w *watchGrpcStream) run() {
if ws := w.nextResume(); ws != nil {
wc.Send(ws.initReq.toPB())
}
case pbresp.Canceled:
case pbresp.Canceled && pbresp.CompactRevision == 0:
delete(cancelSet, pbresp.WatchId)
if ws, ok := w.substreams[pbresp.WatchId]; ok {
// signal to stream goroutine to update closingc
Expand Down
2 changes: 2 additions & 0 deletions etcdserver/api/v3rpc/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,13 @@ func (sws *serverWatchStream) sendLoop() {
}
}

canceled := wresp.CompactRevision != 0
wr := &pb.WatchResponse{
Header: sws.newResponseHeader(wresp.Revision),
WatchId: int64(wresp.WatchID),
Events: events,
CompactRevision: wresp.CompactRevision,
Canceled: canceled,
}

if _, hasId := ids[wresp.WatchID]; !hasId {
Expand Down
1 change: 1 addition & 0 deletions proxy/grpcproxy/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func (w *watcher) send(wr clientv3.WatchResponse) {
Header: &wr.Header,
Created: wr.Created,
CompactRevision: wr.CompactRevision,
Canceled: wr.Canceled,
WatchId: w.id,
Events: events,
})
Expand Down

0 comments on commit 16943f0

Please sign in to comment.