HBASE-12274 Race between RegionScannerImpl#nextInternal() and RegionScannerImpl#close() may produce null pointer exception

This commit is contained in:
Ted Yu 2014-10-17 16:05:31 +00:00
parent 7c87f9c6b5
commit 686e77108a
2 changed files with 8 additions and 1 deletions

View File

@ -4108,6 +4108,10 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver { //
@Override @Override
public boolean nextRaw(List<Cell> outResults, int limit) throws IOException { public boolean nextRaw(List<Cell> outResults, int limit) throws IOException {
if (storeHeap == null) {
// scanner is closed
throw new UnknownScannerException("Scanner was closed");
}
boolean returnResult; boolean returnResult;
if (outResults.isEmpty()) { if (outResults.isEmpty()) {
// Usually outResults is empty. This is true when next is called // Usually outResults is empty. This is true when next is called

View File

@ -2164,9 +2164,12 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
if (rsh != null) { if (rsh != null) {
try { try {
RegionScanner scanner = rsh.s; RegionScanner scanner = rsh.s;
LOG.warn(scannerName + " encountered " + ie.getMessage() + ", closing ...");
scanner.close(); scanner.close();
regionServer.leases.cancelLease(scannerName); regionServer.leases.cancelLease(scannerName);
} catch (IOException e) {} } catch (IOException e) {
LOG.warn("Getting exception closing " + scannerName, e);
}
} }
} }
throw new ServiceException(ie); throw new ServiceException(ie);