fix: use min instead of max when capping write buffer size to Int range#3914
Merged
mbutrovich merged 1 commit intoapache:mainfrom Apr 8, 2026
Merged
Conversation
COMET_SHUFFLE_WRITE_BUFFER_SIZE is a Long (bytesConf) but the protobuf field is int32, so the value must be capped at Int.MaxValue. The code used .max(Int.MaxValue) which always returns Int.MaxValue (~2GB) regardless of the configured value. Should be .min(Int.MaxValue) to preserve smaller values while capping at the Int range.
andygrove
added a commit
to andygrove/datafusion-comet
that referenced
this pull request
Apr 13, 2026
…ge (apache#3914) COMET_SHUFFLE_WRITE_BUFFER_SIZE is a Long (bytesConf) but the protobuf field is int32, so the value must be capped at Int.MaxValue. The code used .max(Int.MaxValue) which always returns Int.MaxValue (~2GB) regardless of the configured value. Should be .min(Int.MaxValue) to preserve smaller values while capping at the Int range.
andygrove
added a commit
that referenced
this pull request
Apr 14, 2026
…ge (#3914) (#3936) COMET_SHUFFLE_WRITE_BUFFER_SIZE is a Long (bytesConf) but the protobuf field is int32, so the value must be capped at Int.MaxValue. The code used .max(Int.MaxValue) which always returns Int.MaxValue (~2GB) regardless of the configured value. Should be .min(Int.MaxValue) to preserve smaller values while capping at the Int range.
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.
Which issue does this PR close?
Closes #.
Rationale for this change
COMET_SHUFFLE_WRITE_BUFFER_SIZEis aLong(configured viabytesConf) but the protobufShuffleWriter.write_buffer_sizefield isint32. The code converts with.max(Int.MaxValue).toInt, which always evaluates toInt.MaxValue(~2GB) regardless of the actual configured value. The intent was to cap the value atInt.MaxValue, which requires.min(Int.MaxValue).The practical impact is limited: the write buffer is a
Vec<u8>that grows organically and flushes when it exceeds the configured threshold. With a 2GB threshold, the buffer effectively never flushes early — it accumulates all serialized IPC bytes for a partition untilflush()is called at the end of processing. This means thespark.comet.exec.shuffle.writeBufferSizeconfig is silently ignored, but it does not cause excessive memory allocation since the buffer only grows to match the actual data written.What changes are included in this PR?
One-line fix:
.max(Int.MaxValue)→.min(Int.MaxValue)inCometNativeShuffleWriter.scala.How are these changes tested?
Existing tests. The fix is a straightforward logic correction with no behavioral change for values already within Int range (which is all practical values).