Aliyun, Dell: Handle EOF in OSS and ECS InputStream read() variants - #17965
Open
damansingh1313 wants to merge 1 commit into
Open
Aliyun, Dell: Handle EOF in OSS and ECS InputStream read() variants#17965damansingh1313 wants to merge 1 commit into
damansingh1313 wants to merge 1 commit into
Conversation
OSSInputStream and EcsSeekableInputStream advanced pos/next and incremented read metrics before checking whether the underlying stream had reached EOF (-1). This corrupted the tracked position by one byte and passed a negative count to the read-bytes counter. GCSInputStream, S3InputStream, and ADLSInputStream already guard against this; apply the same fix here.
Contributor
Author
|
Hi @anoopj @amogh-jahagirdar, |
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.
Why is this change needed?
OSSInputStream(aliyun) andEcsSeekableInputStream(dell) advancepos(andnext, in OSS's case) and increment thereadBytes/readOperationsmetric counters before checking whether the underlying stream has reached EOF (-1). When a read call actually returns-1:read()) or decremented by one byte (read(byte[], int, int), since-1is added topos/next), desyncing the stream's internal position bookkeeping from the real position in the object.readBytescounter is incremented by-1in the buffered-read path, producing a nonsensical negative byte count in read metrics.S3InputStream,GCSInputStream, andADLSInputStreamalready guard against this (fixed in #16055);OSSInputStreamandEcsSeekableInputStreamwere the two implementations left over from that fix. This PR applies the same guard to both.A previous attempt at this exact fix (#16266) was opened but auto-closed for inactivity rather than rejected on merit — this PR picks that up with tests added for both the single-byte and buffered
read()overloads on each class.Closes #16062
What user-facing changes does this include?
None. This only affects internal position tracking and read metrics inside
OSSInputStreamandEcsSeekableInputStreamwhen a read reaches EOF; there is no change to any public API, table format, or configuration.Are there any user-facing changes?
How was this change tested?
Added
testReadSingleEOFandtestReadBufferedEOFto bothTestOSSInputStreamandTestEcsSeekableInputStream, mirroring the tests added forS3InputStream/GCSInputStream/ADLSInputStreamin #16055.Verified locally that all four new tests fail against the pre-fix code and pass after the fix; ran
spotlessCheckfor both modules.