diff --git a/pkg/kv/kvclient/kvcoord/dist_sender_rangefeed.go b/pkg/kv/kvclient/kvcoord/dist_sender_rangefeed.go index 5228c57301a7..b7b8fad40499 100644 --- a/pkg/kv/kvclient/kvcoord/dist_sender_rangefeed.go +++ b/pkg/kv/kvclient/kvcoord/dist_sender_rangefeed.go @@ -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{