diff --git a/paimon-common/src/main/java/org/apache/paimon/reader/RecordReaderIterator.java b/paimon-common/src/main/java/org/apache/paimon/reader/RecordReaderIterator.java index fedb1aeef4f8e..201901fd40132 100644 --- a/paimon-common/src/main/java/org/apache/paimon/reader/RecordReaderIterator.java +++ b/paimon-common/src/main/java/org/apache/paimon/reader/RecordReaderIterator.java @@ -76,6 +76,10 @@ private void advanceIfNeeded() { break; } else { currentIterator.releaseBatch(); + // reset currentIterator, because reader#readBatch will be affected by + // interrupt, which will cause currentIterator#releaseBatch to be executed + // twice. + currentIterator = null; currentIterator = reader.readBatch(); if (currentIterator == null) { break; @@ -89,9 +93,12 @@ private void advanceIfNeeded() { @Override public void close() throws Exception { - if (currentIterator != null) { - currentIterator.releaseBatch(); + try { + if (currentIterator != null) { + currentIterator.releaseBatch(); + } + } finally { + reader.close(); } - reader.close(); } }