Title: Remove expired ack_ids from lease management. · Issue #786 · googleapis/python-pubsub · GitHub
Open Graph Title: Remove expired ack_ids from lease management. · Issue #786 · googleapis/python-pubsub
X Title: Remove expired ack_ids from lease management. · Issue #786 · googleapis/python-pubsub
Description: Possible root cause of: #593 Steps to reproduce High-latency subscriber (e.g. 2 hours) Low message count flow control Solution only works for exactly once delivery subscriptions, since they return invalid_ack_id errors. Code example def ...
Open Graph Description: Possible root cause of: #593 Steps to reproduce High-latency subscriber (e.g. 2 hours) Low message count flow control Solution only works for exactly once delivery subscriptions, since they return ...
X Description: Possible root cause of: #593 Steps to reproduce High-latency subscriber (e.g. 2 hours) Low message count flow control Solution only works for exactly once delivery subscriptions, since they return ...
Opengraph URL: https://github.com/googleapis/python-pubsub/issues/786
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Remove expired ack_ids from lease management.","articleBody":"Possible root cause of: https://github.com/googleapis/python-pubsub/issues/593\r\n\r\n#### Steps to reproduce\r\n\r\n 1. High-latency subscriber (e.g. 2 hours)\r\n 2. Low message count flow control\r\n 3. Solution only works for exactly once delivery subscriptions, since they return invalid_ack_id errors.\r\n\r\n#### Code example\r\n\r\n```\r\n\r\ndef f(x):\r\n set_time = 60\r\n timeout = time.time() + 60*float(set_time) # X minutes from now\r\n print(timeout)\r\n while True:\r\n if time.time() > timeout:\r\n print(\"Time to ack!\")\r\n print(time.time())\r\n break\r\n x * x\r\n\r\ndef create_load(percent_load):\r\n processes = psutil.cpu_count()\r\n to_use = int(processes * (percent_load/100))\r\n print ('utilizing %d cores\\n' % to_use)\r\n pool = Pool(to_use)\r\n pool.map(f, range(to_use))\r\n\r\ndef receive_messages_with_flow_control() -> None:\r\n \"\"\"Receives messages from a pull subscription with flow control.\"\"\"\r\n from concurrent.futures import TimeoutError\r\n from google.cloud import pubsub_v1\r\n\r\n subscriber = pubsub_v1.SubscriberClient()\r\n subscription_path = subscriber.subscription_path(project_id, subscription_id)\r\n\r\n def callback(message: pubsub_v1.subscriber.message.Message) -> None:\r\n print(f\"Received {message.data!r} at {time.time()}.\")\r\n create_load(50)\r\n message.ack()\r\n\r\n # Limit the subscriber to only have ten outstanding messages at a time.\r\n flow_control = pubsub_v1.types.FlowControl(max_messages=1)\r\n\r\n streaming_pull_future = subscriber.subscribe(\r\n subscription_path, callback=callback, flow_control=flow_control\r\n )\r\n\r\n # Wrap subscriber in a 'with' block to automatically call close() when done.\r\n with subscriber:\r\n try:\r\n # When `timeout` is not set, result() will block indefinitely,\r\n # unless an exception is encountered first.\r\n streaming_pull_future.result()\r\n except TimeoutError:\r\n streaming_pull_future.cancel() # Trigger the shutdown.\r\n streaming_pull_future.result() # Block until the shutdown is complete.\r\n```\r\n\r\n### Error trace:\r\n```\r\ngoogle.api_core.exceptions.InvalidArgument: 400 Some acknowledgement ids in the request were invalid. This could be because the acknowledgement ids have expired or the acknowledgement ids were malformed. [reason: \"EXACTLY_ONCE_ACKID_FAILURE\"\r\ndomain: \"pubsub.googleapis.com\"\r\nmetadata {\r\n value: \"PERMANENT_FAILURE_INVALID_ACK_ID\"\r\n}\r\n```\r\n\r\nEven while flow control is activate and CPS client library does not receive messages in streaming_pull_manager._on_response, CPS still delivers messages to the bidi stream, which are buffered. These messages are not lease managed (because the library does not know about them) , so they expire before they are ever sent to a callback.\r\n\r\nWhen one of these expired messages is passed to _on_response, and a receipt modack is sent via send_lease_modacks, if we receive an EOD related INVALID_ACK_ID failure, we should not pass these messages on to be processed, as they are already expired.\r\n","author":{"url":"https://github.com/acocuzzo","@type":"Person","name":"acocuzzo"},"datePublished":"2022-09-21T19:54:12Z","url":"https://github.com/googleapis/python-pubsub/issues/786"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:66a62d5a-c04c-9733-ca50-2b3c30d0ca1b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AF6A:3E61F:25C846:342807:6AEC8B55 |
| html-safe-nonce | 40166c1f2f9b5dc846b203ea53a03602b354ef5ba426ab904b0213e050f4c99d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRjZBOjNFNjFGOjI1Qzg0NjozNDI4MDc6NkFFQzhCNTUiLCJ2aXNpdG9yX2lkIjoiNjc0NzQwOTMyNjIxMDMyMTIzNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ff3949fce6bb41a165fc373d59833d880c65dd0fb6bbc47481d50f3da1816bb6 |
| hovercard-subject-tag | issue:1381422445 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/python-pubsub/786/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e93295599202e365099a3d76eb6a6bb1aae7585bec969bf7147369b87dbb9030/googleapis/python-pubsub/issues/786 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e93295599202e365099a3d76eb6a6bb1aae7585bec969bf7147369b87dbb9030/googleapis/python-pubsub/issues/786 |
| og:image:alt | Possible root cause of: #593 Steps to reproduce High-latency subscriber (e.g. 2 hours) Low message count flow control Solution only works for exactly once delivery subscriptions, since they return ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | acocuzzo |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9e71b15756bc4afd8519e1d2c309d0293587d17d6675d0f439cc304af9ed67ee |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/python-pubsub git https://github.com/googleapis/python-pubsub.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 226992581 |
| octolytics-dimension-repository_nwo | googleapis/python-pubsub |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 226992581 |
| octolytics-dimension-repository_network_root_nwo | googleapis/python-pubsub |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9c2272d26b06ef11573649367fbbb67bfa00cd4f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width