Fix currentSize calculation in BulkIngester - #2113
Open
gaobinlong wants to merge 3 commits into
Open
Conversation
Signed-off-by: Binlong Gao <gbinlong@amazon.com>
gaobinlong
requested review from
Bukhtawar,
VachaShah,
Xtansia,
madhusudhankonda,
reta,
saratvemulapalli and
szczepanczykd
as code owners
August 19, 2026 09:12
Signed-off-by: Binlong Gao <gbinlong@amazon.com>
Signed-off-by: Binlong Gao <gbinlong@amazon.com>
reta
approved these changes
Aug 19, 2026
reta
left a comment
Collaborator
There was a problem hiding this comment.
Thanks @gaobinlong , this is cherrypick of elastic/elasticsearch-java#1167, right?
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.
Description
currentSizein BulkIngester tracks the total byte size of buffered operations, used by canAddOperation() to enforce the maxSize flush threshold. After each flush, line 381 reset it incorrectly:// Before — wrong: operations.size() returns a count (e.g. 3), not bytes (e.g. 30,000)
currentSize = operations.size();
This caused canAddOperation() to compare bytes against a count, making the maxSize-based flush trigger effectively broken — the buffer would almost never flush based on byte size alone.
The fix has two parts:
IngesterOperation previously used a raw RetryableBulkOperation field, causing unchecked cast warnings and requiring callers to go through .repeatableOperation(). It is now IngesterOperation with typed fields and delegation methods (operation(), context(), isSendable(),canRetry(), retries()).
Previously the list stored RetryableBulkOperation (without size). By storing IngesterOperation instead, each entry carries its precomputed byte size. currentSize is now decremented inline as operations are removed during flush:
// After — correct: subtract the actual byte size of each sent operation
currentSize -= op.size();
Issues Resolved
#2112
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.