-
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: ackDeadline cancel context #11210
Comments
By
This is true, but this is why we recommend tweaking I'm not entirely sure why cancelling a context is relevant in the case of duplicated messages. Could you clarify more on that point? |
Yes, you are correct, I should have made it clearer that I refer to the client library.
My goal is to get a cue when the AckDeadline hits, so I can cancel the current process. |
Oooh I found the kinda same issue here. So mbrancato tried to handled context.Canceled from err = sub.Receive(givenCtx, func(ctx context.Context, m *pubsub.Message) {
// Processing that may, at times, exceed the max extension time
time.sleep(1 * time.Minute)
m.Ack()
})
if err != context.Canceled {
// TODO: Handle error.
} So I was thinking that maybe the Could you help me confirm it? |
So this isn't exactly how contexts work. In the above example,
This isn't something the library supports currently as you already found out. I recommend creating a timer inside your handler function to check for how long the message has been processed for. |
I agree. Thank you so much for the explanation!!! |
Is your feature request related to a problem? Please describe.
Duplicated events when the process takes too long.
Describe the solution you'd like
Cancel the given context if ackDeadline has been reached.
Additional context
PubSub pushes the event back to the queue if it takes too long to process. I understand that it's for preventing event loss in case the application crashes. But if the actual event processing takes a long time to perform (says, the Database takes a long time to write), then it may create duplicated events.
Is it better to have the application handle the AckDeadline separately?
Or is it better to have the library cancel the given context?
The text was updated successfully, but these errors were encountered: