Repository navigation
Cut the buffered bytes past a lowered right bound of an Azure read - #120957
Conversation
`ReadBufferFromAzureBlobStorage::setReadUntilPosition` only recorded the new bound and marked the download as not initialized, but left the working buffer as it was. The bytes that the current response had already delivered were still handed out - past a lowered bound too - and the next download was then opened where the previous response ended rather than where the reader was, so the following `nextImpl` failed with the logical error `Attempt to read beyond right offset`, whether the bound was lowered or raised. Setting the bound that was already in effect did the same, because it also dropped the download. A change of the right bound is now a new logical read, the same way a seek is: the working buffer is dropped, the position is kept, and the download is reopened at the position under the new bound. Setting the bound that is already in effect does nothing, so a caller that sets it repeatedly does not reopen the download. `setReadUntilEnd` uses the same path. `src/Disks/tests/gtest_azure_read_buffer_right_bound_change.cpp` lowers the bound below already buffered bytes, raises it after some were consumed, and sets the same bound twice, checking the bytes delivered, the final position, and the offsets the endpoint was asked for. This is one of the independent parts of #115706, which was reverted in #120419.
|
Workflow [PR], commit [3d09934] Summary: ✅
AI ReviewSummaryThis PR fixes Final Verdict
LLVM Coverage ReportMeasured on commit 3d09934.
Changed lines: Changed C/C++ lines covered: 17/18 (94.44%) · Uncovered code |
`ReadBufferFromAzureBlobStorage::setReadUntilPosition` only recorded the new bound and marked the download as not initialized, leaving the working buffer as it was. When the bound was lowered below the end of the buffered bytes, those bytes were still handed out past the bound, and the next download was then opened where the previous response ended rather than at the bound, so the following `nextImpl` failed with the logical error `Attempt to read beyond right offset (100 > 39)`. Formats that adjust the bound mid-read (Parquet, Arrow, ORC through `AsynchronousBoundedReadBuffer`) are the callers. The buffered bytes that lie past a lowered bound are now cut off the working buffer, and the next download, if any, starts at the bound. Buffered bytes within the new bound are kept, so raising the bound goes on reopening the download after them, as before, without downloading them again. Setting the bound that is already in effect no longer drops the download. The download itself is always reopened under a changed bound, since the current one was requested under the previous bound. `src/Disks/tests/gtest_azure_read_buffer_right_bound_change.cpp` lowers the bound below already buffered bytes (fails with the logical error without the change), raises it after some bytes were consumed, and sets the same bound twice, checking the bytes delivered, the final position, and the offsets the fake endpoint was asked for. This is one of the independent parts of #115706, which was reverted in #120419.
Build profile diff (arm_release)Commit See the job log for details. |
…ange-discards-buffer
…ure read `setReadUntilPosition` returned early when the download was already closed by an earlier bound change, so a second change before the next read (raise the bound keeping buffered bytes, then lower it below them) left the bytes past the new bound in the working buffer; they were handed out and the next `nextImpl` failed with `Attempt to read beyond right offset`. The trimming is now applied on every bound change. The abandoned response is also released right away (`data_stream.reset`) instead of staying pinned until the next `initialize` or the destruction of the buffer. Added the test `BoundRaisedThenLoweredBeforeNextRead`. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…ReadUntilPosition` Lifting the right bound is a bound change like any other: it now closes the download opened under the previous bound, releasing the response, and keeps the buffered bytes, which all lie within the lifted bound, instead of dropping them and downloading them again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ange-discards-buffer Master changed `read_until_position` of `ReadBufferFromAzureBlobStorage` to `std::optional<size_t>` and added a simpler bound-change handling that drops the whole working buffer. The conflict is resolved in favour of this PR's reconciliation (keep the buffered bytes within the new bound, cut those past it, close the download), adapted to the optional bound: `setReadUntilEnd` resets the optional instead of passing 0, and a bound of 0 is now a real bound.
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=120957&sha=af0ee540af5c7dc5fd2210c37330c316fe8c28ed&name_0=PR&name_1=Stateless%20tests%20%28arm_asan_ubsan%2C%20azure%2C%20parallel%29 ( |
|
Acknowledged. I'm investigating the |
|
I opened the fix: #123897. The 8-row |
|
🕵 Merged the latest |
Related: #115706
Related: #120419
ReadBufferFromAzureBlobStorage::setReadUntilPositiononly recorded the new bound and marked the download as not initialized, leaving the working buffer as it was. When the bound was lowered below the end of the buffered bytes, those bytes were still handed out past the bound, and the next download was then opened where the previous response ended rather than at the bound, so the followingnextImplfailed with the logical errorAttempt to read beyond right offset (100 > 39). Formats that adjust the bound mid-read (Parquet, Arrow, ORC throughAsynchronousBoundedReadBuffer) are the callers.The buffered bytes that lie past a lowered bound are now cut off the working buffer, and the next download, if any, starts at the bound. Buffered bytes within the new bound are kept, so raising the bound goes on reopening the download after them, as before, without downloading them again. Setting the bound that is already in effect no longer drops the download. The download itself is always reopened under a changed bound, since the current one was requested under the previous bound. (
ReadBufferFromS3drops the whole buffer and reopens at the position on any bound change; this keeps what is still usable instead.)src/Disks/tests/gtest_azure_read_buffer_right_bound_change.cpplowers the bound below already buffered bytes, raises it after some bytes were consumed, and sets the same bound twice, checking the bytes delivered, the final position, and the offsets the fake endpoint was asked for. Without the change the first fails withAttempt to read beyond right offset (100 > 39).This is one of the independent parts of #115706, which was reverted in #120419.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix the logical error
Attempt to read beyond right offsetwhen the right bound of a read from Azure Blob Storage is lowered below bytes the reader has already buffered.Workflow [PR]
Sync PR [sync-upstream/pr/120957]
Version info
26.10.1.2077-master(included in26.10and later)