Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

Commit 4361e67

Browse files
beltranacocuzzogcf-owl-bot[bot]
authored
fix: batch at most 1,000 ack ids per request (#802)
Co-authored-by: Anna Cocuzzo <[email protected]> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent fa23503 commit 4361e67

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

google/cloud/pubsub_v1/subscriber/_protocol/dispatcher.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,8 @@
5959
"""The maximum amount of time in seconds to wait for additional request items
6060
before processing the next batch of requests."""
6161

62-
_ACK_IDS_BATCH_SIZE = 2500
62+
_ACK_IDS_BATCH_SIZE = 1000
6363
"""The maximum number of ACK IDs to send in a single StreamingPullRequest.
64-
65-
The backend imposes a maximum request size limit of 524288 bytes (512 KiB) per
66-
acknowledge / modifyAckDeadline request. ACK IDs have a maximum size of 164
67-
bytes, thus we cannot send more than o 524288/176 ~= 2979 ACK IDs in a single
68-
StreamingPullRequest message.
69-
70-
Accounting for some overhead, we should thus only send a maximum of 2500 ACK
71-
IDs at a time.
7264
"""
7365

7466
_MIN_EXACTLY_ONCE_DELIVERY_ACK_MODACK_RETRY_DURATION_SECS = 1

tests/unit/pubsub_v1/subscriber/test_dispatcher.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def test_ack_splitting_large_payload():
437437
dispatcher_.ack(items)
438438

439439
calls = manager.send_unary_ack.call_args_list
440-
assert len(calls) == 3
440+
assert len(calls) == 6
441441

442442
all_ack_ids = {item.ack_id for item in items}
443443
sent_ack_ids = collections.Counter()
@@ -689,7 +689,7 @@ def test_modify_ack_deadline_splitting_large_payload():
689689
dispatcher_.modify_ack_deadline(items)
690690

691691
calls = manager.send_unary_modack.call_args_list
692-
assert len(calls) == 3
692+
assert len(calls) == 6
693693

694694
all_ack_ids = {item.ack_id for item in items}
695695
sent_ack_ids = collections.Counter()

0 commit comments

Comments
 (0)