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): fix messages delivered multiple times despite a long ACK deadline #9525

Merged
merged 4 commits into from
Nov 22, 2019

Conversation

plamut
Copy link
Contributor

@plamut plamut commented Oct 23, 2019

Fixes #9252.

This PR addresses the problem with some of the messages being re-delivered too early, because their acknowledge deadline is set to short, and is not properly extended.

The issue was sometimes happening to the received messages that exceeded the flow control limits, and were thus put on hold.

The fix adds all messages to the lease management, but at the same time adjusts the load calculation to not include the messages on hold. The core pause/resume logic effectively remains the same, except that now, the ACK deadlines are automatically being extended for all received messages, and a fixed stream ACK deadline is not needed anymore.

Contrary to the original fix, this PR does not require additional client permissions.

How to test

  • Run the example subscriber code linked in the issue description. Use max_messages == 1, and make sure that the sleep interval in the message callback is longer than the current default stream ACK deadline (60 seconds).
  • Publish two messages to the topic in a single batch. This will cause the server to send them both in a single stream response, causing one of them to en up in the on hold buffer.
  • Wait ~2 * sleep_delay or so until both messages are processed and acknowledged.

Actual result (before the fix):
The second message is re-delivered, because its ACK deadline was missed.

Expected result (after the fix):
Both messages are delivered only once, because their ACK deadlines were properly extended in the background.

@plamut plamut added the api: pubsub Issues related to the Pub/Sub API. label Oct 23, 2019
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Oct 23, 2019
This is to prevent the messages that are put on hold from unnecessarily
timing out too soon, causing the backend to re-send them.
Even the messages received that exceed the maximum load (as defined by
flow control) must be lease-mananged to avoid unnecessary ACK deadline
expirations, but since they are not dispatched (yet) to user callbacks,
they should not contribute to the overall load.

Without this change, the total load could be overestimated, resulting
in an indefinitely paused message stream, and messages not being
dispatched to callbacks when they should be.
This should not happen, but if it does, it is a bug in the
StreamingPullManager logic, and we should know about it.
With all the messages lease-managed (even those on hold), there is no
need to have a fixed default value.
@plamut plamut added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 11, 2019
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 11, 2019
@pellard1016
Copy link

Hello, I am still seeing this issue. I set a subscription acknowledgement deadline to 600 seconds, however it is pushing the same message every 3 minutes.
sub
cloudFunctinoLog

@plamut
Copy link
Contributor Author

plamut commented Nov 20, 2019

@pellard1016 This pull request has not been merged yet, thus the fix is not yet available.

Or did you actually try with the changes submitted here?
(in which case the PR needs another look)

@pellard1016
Copy link

pellard1016 commented Nov 20, 2019 via email

Copy link
Contributor

@pradn pradn left a comment

Choose a reason for hiding this comment

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

First pass of comments added.

@plamut plamut requested a review from pradn November 22, 2019 16:51
@googleapis googleapis deleted a comment from plamut Nov 22, 2019
@plamut plamut merged commit d4c440b into googleapis:master Nov 22, 2019
@plamut plamut deleted the iss-9252-b branch November 22, 2019 20:21
@jawlitkp
Copy link

I am facing the same issue, is this fix available now?

@plamut
Copy link
Contributor Author

plamut commented Jan 9, 2020

@jawlitkp The fix for this was released with PubSub v1.1.0.

In which PubSub version do you face the issue, in the latest one or in one of the older ones?

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.

Pub/Sub: buffered messages delivered multiple times ignoring acknowledgment deadline
6 participants