JingsongLi commented on code in PR #9183:
URL: https://github.com/apache/paimon/pull/9183#discussion_r3763490380
##########
paimon-core/src/main/java/org/apache/paimon/disk/BufferFileChannelReader.java:
##########
@@ -60,8 +61,16 @@ public boolean readBufferFromFileChannel(Buffer buffer)
throws IOException {
}
checkArgument(buffer.getSize() == 0, "Buffer not empty");
- fileChannel.read(buffer.getNioBuffer(0, size));
+ readFully(buffer.getNioBuffer(0, size));
buffer.setSize(size);
return fileChannel.size() - fileChannel.position() == 0;
}
+
+ private void readFully(ByteBuffer target) throws IOException {
+ while (target.hasRemaining()) {
+ if (fileChannel.read(target) < 0) {
+ throw new EOFException("Premature end of file while reading
buffer");
Review Comment:
Could we keep the `readFully` loop but avoid throwing `EOFException` here?
`ChannelReaderInputViewIterator` catches every `EOFException` and converts it
to `null` (normal end-of-input). Therefore, if a spill block is actually
truncated—for example, its header declares 10 bytes but only 5 remain—this
exception is swallowed and the merge can silently drop the remaining records.
`FileChannel.read` reports physical EOF with `-1`; before this change, this
reader did not synthesize `EOFException` for a truncated physical block. Please
throw a regular `IOException` (or a dedicated corruption exception) so that
only the `numBlocksRemaining == 0` path in `ChannelReaderInputView` uses
`EOFException`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]