-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
pubsub: expired messages clog up flow control #9309
Comments
Can this be added to https://github.com/googleapis/google-cloud-go/blob/main/pubsub/CHANGES.md as a breaking change? I understand the importance of this bug fix, and that compatible API usage is documented for versions 1.19+. |
@nh731685 Sorry this caused a problem for you. This fix was merely intended to make it so that if |
In our flow, the callback completes before Ack or Nack. Ack or Nack are called in another goroutine, anywhere between tens of milliseconds up to 10 minutes after the callback completes. This other goroutine that calls Ack/Nack is a gRPC handler. We relied on the flow control of MaxOutstandingMessages to protect the system from becoming overloaded. With this bug fix, MaxOutstandingMessages is no longer honored when Ack is called asynchronously. I understand that as a safe library pattern, protecting the user from losing PubSub messages and eventually deadlocking is desirable. Hypothetically, we can work around this change by adjusting the callback to wait for some Ack/Nack hint on a channel before letting the callback return. |
I see. Calling I do have plans to support acking/nacking outside the callback, tracked in #8200. In theory, this would require to rewriting the lease management system to be "aware" of in-flight ack/nacks and when messages expire. This new system would need to guard against the issue of dropping messages when acks are still in flight and also freeing up flow control when messages expire. |
Thank you, Alex. It sounds like my team should use a workaround such as the one described above so we can take library updates. |
Yeah I think the workaround sounds reasonable. I'll close out this issue, but recommend commenting on #8200 if you have more concerns here. |
Client
PubSub
Environment
all
Code
Expected behavior
With low flow control set (e.g.
MaxOutstandingMessages = 1
), expired messages do not clog up flow control.Actual behavior
Flow control is blocked since
release
is never called. No new messages can be processed.Additional context
Currently when messages expire, it means the lease management mechanism deletes it from the map that tracks how long to process it for. However, cleanup of resources (including releasing flow control resources), happens only when the message's done function is called.
Flow control release should happen after the end of the user callback (passed into
Receive
).The text was updated successfully, but these errors were encountered: