-
Notifications
You must be signed in to change notification settings - Fork 230
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
message.ack() not working in the 3.2.x releases #1665
Comments
@uvesten I made a new test sample to kind of close the loop, code-wise, and it seems to be working for me:
The output I get is:
(with a pause after the last 'sending', and sometimes the received messages come out of order, which is all within expectations) Can you post some (sensitive info excluded) metadata about your topic and subscription? Some stuff definitely changed between 3.0 and 3.2, and it's possible something else is triggering it.
|
Forgot to say: |
Thanks for the analysis, @feywind! In your code example, though, how do you see that the messages got Subscription metadata:
(I also just get the name as metadata for the topic) |
Ah, you make a good point there... I commented out the I'm not quite sure what's going on there in your app, but I'll add this to a list of things to ask around about. If you don't need the new features in the versions that don't work for you, the immediate action I'd take is just downgrading versions for now. Maybe also try 3.1.x to see if that still works. |
Starting in 3.2.x the behavior for close changed nodejs-pubsub/src/message-queues.ts Lines 180 to 208 in d32ac91
https://github.com/googleapis/nodejs-pubsub/blob/v3.1.1/src/subscriber.ts#L447-L459 followed by acking a message if you had a callback for instance https://github.com/googleapis/nodejs-pubsub/blob/v3.1.1/src/subscriber.ts#L431-L438 https://github.com/googleapis/nodejs-pubsub/blob/v3.1.1/src/message-queues.ts#L110-L122 that would cause a flush to happen on a timeout for instance ^ However, now in 3.2.x and above, the behavior for close will also close the ack queue https://github.com/googleapis/nodejs-pubsub/blob/v3.2.0/src/subscriber.ts#L565-L580 https://github.com/googleapis/nodejs-pubsub/blob/v3.2.0/src/message-queues.ts#L142-L161 This would mean that any call to https://github.com/googleapis/nodejs-pubsub/blob/v3.2.0/src/message-queues.ts#L180-L208 Lesson learned, in newer versions, if you wish to ack any message, you need to be sure that the subscription is open. If you have called close, prior to calling ack on any message make sure to call open. In doing so however, your ack message queue will be completely wiped clean and re-initialized. For the most part this shouldn't be a problem since you are only filling up that ack queue after open anyway. |
@nyxtom Thanks for your detailed comment. I'll add this to our meeting to talk about... I'm not sure if it's a breaking change or not, since we haven't been very precise up to now about what close() does, exactly. But the surprise is also not very nice, so we might want to re-visit this. |
fwiw, updating the close behaviour has been added to the schedule for Q4, so hopefully there will be a nice, deterministic shutdown method soon. |
Closed in favour of #1917 |
(This seems related to the previous issues #1653 and #1648)
We've been using this package with no issues (and no code changes) on our side up to version 3.0.1. After upgrading to version 3.2.0 or 3.2.1 message acknowledgements are silently being ignored. It's quite an insidious bug, since the behavior of
message.ack()
is supposed to be unchanged (we're not using exactly-once delivery), and since it's a void function it's not really possible to see that the behavior has actually changed.If this was intended, it should be a major version upgrade, IMHO, since it breaks existing code.
Environment details
@google-cloud/pubsub
version: 3.2.0, 3.2.1Steps to reproduce
The above works as expected (i.e. the messages get acknowledged) using 3.0.1, but it fails (messages remain on the topic, don't get acknowledged) using 3.2.0 and 3.2.1
The text was updated successfully, but these errors were encountered: