Skip to content

Commit

Permalink
HBASE-25507 Leak of ESTABLISHED sockets when compaction encountered "…
Browse files Browse the repository at this point in the history
…java.io.IOException: Invalid HFile block magic"
  • Loading branch information
sunhelly committed Jan 16, 2021
1 parent 3488c44 commit 06b26f3
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,11 @@ protected final List<Path> compact(final CompactionRequestImpl request,
dropCache = this.dropCacheMinor;
}

List<StoreFileScanner> scanners =
createFileScanners(request.getFiles(), smallestReadPoint, dropCache);
InternalScanner scanner = null;
boolean finished = false;
List<StoreFileScanner> scanners = null;
try {
scanners = createFileScanners(request.getFiles(), smallestReadPoint, dropCache);
/* Include deletes, unless we are doing a major compaction */
ScanType scanType = scannerFactory.getScanType(request);
ScanInfo scanInfo = preCompactScannerOpen(request, scanType, user);
Expand All @@ -345,7 +345,18 @@ protected final List<Path> compact(final CompactionRequestImpl request,
+ store.getRegionInfo().getRegionNameAsString() + " because it was interrupted.");
}
} finally {
Closeables.close(scanner, true);
// createScanner may fail when seeking hfiles encounter Exception, e.g. even only one hfile
// reader encounters java.io.IOException: Invalid HFile block magic:
// \x00\x00\x00\x00\x00\x00\x00\x00
// and then scanner will be null, but scanners for all the hfiles should be closed,
// or else we will find leak of ESTABLISHED sockets.
if (scanner == null && scanners != null) {
for (StoreFileScanner sfs : scanners) {
sfs.close();
}
} else {
Closeables.close(scanner, true);
}
if (!finished && writer != null) {
abortWriter(writer);
}
Expand Down

0 comments on commit 06b26f3

Please sign in to comment.