HBASE-26944 Possible resource leak while creating new region scanner (#4339)

* HBASE-26944 Possible resource leak while creating new region scanner

Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
Pankaj 2022-04-15 11:34:25 +05:30 committed by GitHub
parent f990f56e8e
commit 62e3efccef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -3203,9 +3203,17 @@ public class RSRpcServices extends HBaseRpcServicesBase<HRegionServer>
RegionScannerImpl coreScanner = region.getScanner(scan);
Shipper shipper = coreScanner;
RegionScanner scanner = coreScanner;
try {
if (region.getCoprocessorHost() != null) {
scanner = region.getCoprocessorHost().postScannerOpen(scan, scanner);
}
} catch (Exception e) {
// Although region coprocessor is for advanced users and they should take care of the
// implementation to not damage the HBase system, closing the scanner on exception here does
// not have any bad side effect, so let's do it
scanner.close();
throw e;
}
long scannerId = scannerIdGenerator.generateNewScannerId();
builder.setScannerId(scannerId);
builder.setMvccReadPoint(scanner.getMvccReadPoint());