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 f59978e commit c59c927
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}
}

0 comments on commit c59c927

Please sign in to comment.