GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: ACK deadline set for received messages can be too low by plamut · Pull Request #416 · googleapis/python-pubsub

This repository was archived by the owner on Oct 13, 2026. It is now read-only.

Conversation

@plamut

@plamut plamut commented May 21, 2021

Copy link
Copy Markdown
Contributor

Fixes #413.

This PR makes sure that the ACK deadline set for the received messages is always consistent with what the leaser uses internally when extending the ACK deadlines for the leased messages.

See the issue description and a comment explaining a possible sequence of events that lead to a bug.

PR checklist

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@plamut
fix: use the same initial ACK deadline as leaser
223a986
When a message is received, the initial MODACK value used should be
the same value currently used by leaser. This makes sure the leaser
will wake up and extend the ACK deadline before the initial one
expires.
@plamut
plamut requested a review from a team May 21, 2021 10:22
@product-auto-label product-auto-label Bot added the api: pubsub Issues related to the googleapis/python-pubsub API. label May 21, 2021
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label May 21, 2021
@plamut
Make max_duration_per_lease_extension high enough
dc2b233
If flow_control.max_duration_per_lease_extension is set to too low a
value, it is adjusted to the minimum ACK deadline.
@plamut
plamut force-pushed the iss-413 branch from 5407e01 to 82e1166 Compare May 21, 2021 11:08
@plamut
Bump histogram test coverage to 100%
aed7784
@plamut
plamut force-pushed the iss-413 branch from 82e1166 to aed7784 Compare May 21, 2021 11:25
@plamut

plamut commented May 21, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Hmm... this PR fixes the issue caused by directly using the p99 value that can be different from manager.ack_deadline used by the leaser, but even if using manager.ack_deadline, a message can still expire.

Consider - manager.ack_deadline is currently 600, because processing on of the messages took 1000 = minutes. The leaser goes to sleep for 0.9 * 600 = 540 seconds. While the leaser is asleep, more messages are received and processed quickly, dropping the histogram's p99 value to 10 seconds, consequently adjusting the value of manager._ack_deadline, too.

When yet more messages arrive, the shortened ACK deadline will be used for them while the leaser is still asleep (due to the previous "long" deadline). The leaser will not wake in time to extend the deadlines of these new messages.

Bottom line - the ACK deadline should probably not change while the leaser is asleep so that _on_response() does not use a deadline that could be shorter than the current sleep period of the leaser.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@plamut plamut added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label May 21, 2021
@plamut
Only update ACK deadline through leaser
ee29da4
The ACK deadline is dynamically being adjusted based on ACK data,
but an updated deadline value must not be used for the new messages
that arrive while the leaser thread is still sleeping.

Doing so could result in the messages' ACK deadlines expiring before
the leaser wakes up and has a chance of extending the deadlines for
these messages. An updated ACK deadline value for new messages is thus
only used when the leaser starts using it, too.
@plamut

plamut commented May 21, 2021

Copy link
Copy Markdown
Contributor Author

Fixed, only the leaser now updates the manager.ack_deadline value. This means that the leased messages will never use an ACK deadline that is shorter than the duration of the leaser's current sleep period.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@plamut plamut removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label May 21, 2021
@plamut
plamut requested a review from pradn May 21, 2021 16:30
@plamut plamut added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 21, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 21, 2021
@plamut plamut added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 22, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 22, 2021
jimfulton
jimfulton reviewed May 25, 2021
View reviewed changes
Comment thread google/cloud/pubsub_v1/subscriber/_protocol/histogram.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google/cloud/pubsub_v1/subscriber/_protocol/leaser.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@plamut
Be more explicit about the default Histogram.min
64e4d7a
jimfulton
jimfulton approved these changes May 26, 2021
View reviewed changes
@plamut
Avoid hardcoded values in Histogram docstring
d772cab
@plamut plamut added the automerge Merge the pull request once unit tests and other checks pass. label May 26, 2021
@gcf-merge-on-green
gcf-merge-on-green Bot merged commit e907f6e into googleapis:master May 26, 2021
@gcf-merge-on-green gcf-merge-on-green Bot removed the automerge Merge the pull request once unit tests and other checks pass. label May 26, 2021
@release-please release-please Bot mentioned this pull request Aug 11, 2022
chore(main): release 2.13.6 #761
Merged
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@pradn pradn Awaiting requested review from pradn
1 more reviewer
@jimfulton jimfulton jimfulton approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

api: pubsub Issues related to the googleapis/python-pubsub API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

The initial ACK deadline set for the messages received could be too low

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@plamut @jimfulton @yoshi-kokoro
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.