PDGGK opened a new pull request, #9474:
URL: https://github.com/apache/paimon/pull/9474

   ### Purpose
   
   `BTreeIndexWriter.finish()` does six writes before releasing the file, all 
inside one try whose catch only rethrows:
   
   ```java
   try {
       flush();
       writer.flush();
       BlockHandle nullBitmapHandle = writeNullBitmap();
       BloomFilterHandle bloomFilterHandle = writer.writeBloomFilter();
       BlockHandle indexBlockHandle = writer.writeIndexBlock();
       ...
       writer.writeSlice(footerEncoding);
   
       out.close();
   } catch (IOException e) {
       throw new RuntimeException("Error in closing BTree index writer", e);
   }
   ```
   
   A write that fails part way through skips `out.close()`, so the handle stays 
open. A full disk is the ordinary cause, and it is exactly when an index write 
is most likely to fail.
   
   The constructor has the same gap in the other direction:
   
   ```java
   this.out = indexFileWriter.newOutputStream(this.fileName);
   this.keySerializer = keySerializer;
   this.comparator = keySerializer.createComparator();
   this.writer = new SstFileWriter(out, blockSize, null, compressionFactory);
   ```
   
   If anything after the open throws, the constructor never returns and nothing 
else holds the stream.
   
   `BTreeIndexReader` guards its own construction this way already, so this 
makes the read and write sides agree.
   
   ### Tests
   
   `BTreeIndexWriterCloseTest#testFinishReleasesTheFileWhenWritingFails` gives 
the writer an output stream with a fixed capacity that starts failing with `no 
space left on device` once it is exhausted, writes 200 rows, and asserts 
`finish()` still surfaces the failure and the stream is closed.
   
   Reverting the change turns it red on the close counter (`Expecting 
AtomicInteger(0) to have value: 1`).
   
   A note on how the injection is shaped: an earlier version failed the stream 
from `flush()`, which never fired — `SstFileWriter.flush()` does not reach the 
underlying stream, so the test passed while proving nothing. Failing on write 
once a capacity is exhausted is what actually reaches the path.
   
   `mvn test -pl paimon-common -Dtest='org.apache.paimon.globalindex.**'` — 347 
tests, all passing. spotless and checkstyle clean.
   


-- 
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]

Reply via email to