Skip to content

Fix/update inventory on nacks#2071

Open
Luisgustavom1 wants to merge 3 commits intogoogleapis:mainfrom
Luisgustavom1:fix/update-inventory-on-nacks
Open

Fix/update inventory on nacks#2071
Luisgustavom1 wants to merge 3 commits intogoogleapis:mainfrom
Luisgustavom1:fix/update-inventory-on-nacks

Conversation

@Luisgustavom1
Copy link

Fixes #2070 🦕

@Luisgustavom1 Luisgustavom1 requested a review from a team July 19, 2025 12:04
@Luisgustavom1 Luisgustavom1 requested a review from a team as a code owner July 19, 2025 12:04
@product-auto-label product-auto-label bot added size: s Pull request size is small. api: pubsub Issues related to the googleapis/nodejs-pubsub API. labels Jul 19, 2025
@Luisgustavom1 Luisgustavom1 force-pushed the fix/update-inventory-on-nacks branch from 89bf54e to 9a2ca06 Compare July 19, 2025 15:46
const latency = (Date.now() - startTime) / 1000;
this._latencies.add(latency);

this._inventory.remove(message);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we wouldn't want to remove it in the case of a legit modack, just in the case of nack. But yeah, this clearly seems like an oversight.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with not removing the message from the inventory is that the inventory will remain full forever in case of many nacks. If my maxMessages is 5 and I had 5 nacks, the inventory will remain full and the subscription will never receive messages again.

This is strange and hidden behavior. Some people have lost a little of their sanity trying to understand what was going on and why their subscription never received messages again.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. When the user calls ack or nack, they're clearing asking for some kind of non-leasing behaviour, so removing it from the inventory in that case makes sense. For the (internal) modack case, though, we don't want to remove it. A nack is just a modack with a time of 0, so probably just adding a check there before removing it would be fine.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, but excuse me, I'm not sure I understood correctly. If the modnack is a nack with a time of 0, what check do you think we should perform before clearing the inventory?

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 googleapis/nodejs-pubsub API. size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When use exact-once-delivery, and allowExcessMessages is false, nacking a number of messages equal to maxMessages subscriber stop of receive messages

2 participants