-
Notifications
You must be signed in to change notification settings - Fork 1.5k
pubsub: identified memory leak in receiver #10094
Copy link
Copy link
Closed
Labels
api: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Metadata
Metadata
Assignees
Labels
api: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Client
PubSub
Environment
Any
Go Environment
go version 1.21
Likely irrelevant
Expected behavior
Long-running processing, making repeated calls to
Subscription.Receive()does not leak resources.Actual behavior
gRPC
StreamingPullstreams remain open in the backgroud and accumulate over time.Root cause
pullStream.cancel()never gets called, andCloseSend()is not enough to actually terminate the underlying stream.Code
A minimal fix would be e.g.
Or this could be done either further up or down the call chain. For instance get
Subscription.Receiveto do it after everything else is done, so that the cancelation error does not appear sooner (which however may lead to unnecessary wait?).Additional context
This could well be the same issue as #5888 and #5265, however those were closed, and I thought it would make more sense to reopen a new one with the full diagnostics.