Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pubsub): prevent draining error return for Receive #4733

Merged
merged 3 commits into from Sep 14, 2021

Conversation

hongalex
Copy link
Member

@hongalex hongalex commented Sep 9, 2021

In receive_scheduler.go, adding a new message after the context passed into Receive is cancelled will result in a library-defined draining error. This is poor behavior as the condition which this happens is out of the user's control (simultaneous Shutdown + ReceiveScheduler.Add()). This PR mitigates this by

  1. Stop message pulling if the context is cancelled
  2. Nack messages that have have already been received (don't extend their lease)

In addition, since it's unlikely for messages to be added, this PR also removes the draining error entirely and allows messages to be added. This is very unlikely and is still preferable to surfacing an unactionable error to the user.

Fixes #4718

@hongalex hongalex requested review from a team as code owners September 9, 2021 03:40
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Sep 9, 2021
@product-auto-label product-auto-label bot added the api: pubsub Issues related to the Pub/Sub API. label Sep 9, 2021
@hongalex hongalex merged commit c6d5189 into googleapis:master Sep 14, 2021
@hongalex hongalex deleted the fix-pubsub-draining branch September 14, 2021 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the Pub/Sub API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pubsub: receive returns an error when canceled
2 participants