Skip to content

Commit

Permalink
kvclient: fix gRPC stream leak in rangefeed client
Browse files Browse the repository at this point in the history
When the DistSender rangefeed client received a `RangeFeedError` message
and propagated a retryable error up the stack, it would fail to close
the existing gRPC stream, causing stream/goroutine leaks.

Release note (bug fix): Fixed a goroutine leak when internal rangefeed
clients received certain kinds of retriable errors.
  • Loading branch information
erikgrinaker committed Apr 28, 2022
1 parent ce57830 commit 84a67d1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/kv/kvclient/kvcoord/dist_sender_rangefeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,10 @@ func (ds *DistSender) singleRangeFeed(
eventCh chan<- *roachpb.RangeFeedEvent,
onRangeEvent onRangeEventCb,
) (hlc.Timestamp, error) {
// Ensure context is cancelled on all errors, to prevent gRPC stream leaks.
ctx, cancel := context.WithCancel(ctx)
defer cancel()

args := roachpb.RangeFeedRequest{
Span: span,
Header: roachpb.Header{
Expand Down

0 comments on commit 84a67d1

Please sign in to comment.