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 fedb1aeef4f8..5a807c6f115c 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,9 @@ private void advanceIfNeeded() { break; } else { currentIterator.releaseBatch(); + // 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 +92,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(); } }