-
Notifications
You must be signed in to change notification settings - Fork 344
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
[Issue 513] Correct apparent logic error in batchContainer's hasSpace() method #678
Conversation
The tests now seem to be failing on |
It's probably unrelated since the tests passed for the other go versions. The concerning part is there may be a flaky I started a retest |
I would guess that it's probably this part of
Since the sleep above happens inside a new goroutine, and |
I added From the results of that test, it looks like the |
We should use this
Because this will accommodate an individual message when batch is disabled. Currently this configuration fails at [unable to add message to batch]
|
…d on the results of the test, change the < in hasSpace() to be a <=.
6f30893
to
09705b8
Compare
Made the additional tweak as suggested by @zzzming, also cleaned up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM +1
Fixes issue #513.
This issue was previously partially addressed by @zzzming in PR #528.
Motivation
Following PR #528, the logic for the
hasSpace()
function, which is used to determine whether a batch container has enough space for a new message, reads:Currently, then, the batch container will be considered to have space (be non-full) until both the max-messages and the max-size limits are hit.
I think that is incorrect. Nearby in the code, the batch container is considered to be full if either of the conditions are hit:
Because the logical rule is
!(A || B) = (!A) && (!B)
, the||
inhasSpace()
should be an&&
.Modifications
Change the
||
inhasSpace()
to an&&
, so that the container will be considered full if either limit is hit.Verifying this change
This change is a trivial rework / code cleanup without any test coverage.Added
TestMaxBatchSize()
.Documentation