fix(pubsub): Publisher byte threshold off by one error#4651
Merged
PhongChuong merged 2 commits intogoogleapis:mainfrom Feb 13, 2026
Merged
fix(pubsub): Publisher byte threshold off by one error#4651PhongChuong merged 2 commits intogoogleapis:mainfrom
PhongChuong merged 2 commits intogoogleapis:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4651 +/- ##
==========================================
+ Coverage 95.01% 95.03% +0.01%
==========================================
Files 196 196
Lines 7530 7551 +21
==========================================
+ Hits 7155 7176 +21
Misses 375 375 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
suzmue
reviewed
Feb 11, 2026
|
|
||
| let mut publish_rxs = VecDeque::new(); | ||
| publish_random_data!(publish_rxs, actor_tx, 1); | ||
| // We flush here otherwise the last message will await forever since it never exceed the byte threshold. |
Collaborator
There was a problem hiding this comment.
aside: I think actually with start_paused = true, the testing framework will fire the timer if its the only thing that can happen, so this might not be necessary.
Collaborator
Author
There was a problem hiding this comment.
The flush is needed here because the timer is in the Dispatcher.
92c6f9e to
b442f5e
Compare
Collaborator
Author
|
@suzmue , thanks for the review. PTAL. |
suzmue
approved these changes
Feb 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR fix the issue where the Publisher configured byte threshold is not respected. In the bug, the Publisher will add the next message to the pending batch until the batch size is greater then the byte threshold. The correct behavior is to batch the messages such that each batch size is less or equal to the configured byte threshold.
In the fix, we add the next message to the batch only if the batch will stay within the configured byte threshold. This is done lazily and the pending batch is not Send until we know that the next message will not fit.