wombatu-kun commented on code in PR #20023:
URL: https://github.com/apache/hudi/pull/20023#discussion_r4070081056


##########
hudi-common/src/main/java/org/apache/hudi/common/table/read/lsm/SpillableLsmRecordIterator.java:
##########
@@ -166,6 +166,13 @@ private void 
closeSourceIterator(ClosableIterator<BufferedRecord<T>> sourceItera
       if (spillFailure != null) {
         spillFailure.addSuppressed(e);
       } else {
+        // Closing the source iterator failed, so construction cannot complete 
and the outer reader
+        // cannot call close() on this spill iterator. Delete its spill file 
here to avoid leaking it.
+        try {

Review Comment:
   nit: this try/catch duplicates `CloseableUtils.closeSuppressing`; 
`CloseableUtils.closeSuppressing(this::deleteSpillFile, e);` covers it in one 
line.



##########
hudi-common/src/main/java/org/apache/hudi/common/table/read/lsm/SpillableLsmRecordIterator.java:
##########
@@ -166,6 +166,13 @@ private void 
closeSourceIterator(ClosableIterator<BufferedRecord<T>> sourceItera
       if (spillFailure != null) {
         spillFailure.addSuppressed(e);
       } else {
+        // Closing the source iterator failed, so construction cannot complete 
and the outer reader

Review Comment:
   The same leak remains one level up: when this constructor throws inside 
`LsmFileGroupRecordIterator.initializeReaders`, the readers already in 
`sortedRunReaders` (earlier spill iterators included) are never closed, so 
their spill files are still orphaned. Should `initializeReaders` close them 
before rethrowing, in this PR or as a follow-up?



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