PDGGK opened a new issue, #9162:
URL: https://github.com/apache/paimon/issues/9162

   ### Search before asking
   
   - [x] I searched in the [issues](https://github.com/apache/paimon/issues) 
and found nothing similar.
   
   ### Paimon version
   
   master
   
   ### Compute Engine
   
   Any — this is on the merge-tree compaction path, not engine-specific.
   
   ### Minimal reproduce step
   
   Code inspection of `SortMergeReaderWithMinHeap.close()`.
   
   ### What doesn't meet your expectations?
   
   `SortMergeReaderWithMinHeap.close()` releases one `RecordReader` per sorted 
run being merged, spread across three loops, and every call is a bare `close()`:
   
   ```java
   public void close() throws IOException {
       for (RecordReader<KeyValue> reader : nextBatchReaders) {
           reader.close();
       }
       for (Element element : minHeap) {
           element.iterator.releaseBatch();
           element.reader.close();
       }
       for (Element element : polled) {
           element.iterator.releaseBatch();
           element.reader.close();
       }
   }
   ```
   
   The first call to throw abandons the rest of its own loop **and both loops 
after it**. This is not a two-resource case — there is one reader per sorted 
run, each holding an open data file, and it runs on the compaction path. One 
unreadable file therefore strands every descriptor behind it for the remainder 
of the merge.
   
   `element.iterator.releaseBatch()` has the same exposure: it declares no 
checked exception but can still throw, and when it does the `close()` on the 
very next line is skipped.
   
   ### Anything else?
   
   The sibling `SortMergeReaderWithLoserTree.close()` is unaffected — it 
delegates to a single `loserTree.close()`.
   
   `IOUtils.closeAll` looks like the natural fix but does not fit here: it 
declares `throws Exception`, and both current callers 
(`FormatTableFileWriter:93`, `FileChannelManagerImpl:126`) widened their own 
signatures to match. This method overrides `RecordReader.close() throws 
IOException` and cannot. `ExceptionUtils.firstOrSuppressed` is the right tool, 
and its javadoc already gives this close-loop as its worked example.
   
   The same shape exists in three other places, all lower stakes than this one 
— happy to file them separately if useful:
   
   - `BucketedPrimaryKeyIndexMaintainer:310`
   - `SortLookupStoreReader:83`
   - `SstFileReader:171`
   
   ### Are you willing to submit a PR?
   
   - [x] I'm willing to submit a PR!
   


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