Skip to content

Commit

Permalink
[common] fix the problem that RecordReader may not be closed in async…
Browse files Browse the repository at this point in the history
…hronous compact thread.
  • Loading branch information
liming30 committed Nov 13, 2023
1 parent 194bb75 commit 38495a1
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}
}

0 comments on commit 38495a1

Please sign in to comment.