HBASE-16012 Major compaction can't work due to obsolete scanner read point in RegionServer (Guanghao Zhang)

This commit is contained in:
tedyu 2016-06-22 02:08:45 -07:00
parent ef90ecc00c
commit 2846113b59
2 changed files with 34 additions and 13 deletions

View File

@ -5656,12 +5656,8 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
}
}
initializeKVHeap(scanners, joinedScanners, region);
} catch (IOException e) {
// close all already instantiated scanners before throwing the exception
for (KeyValueScanner scanner : instantiatedScanners) {
scanner.close();
}
throw e;
} catch (Throwable t) {
throw handleException(instantiatedScanners, t);
}
}
@ -5674,6 +5670,26 @@ public class HRegion implements HeapSize, PropagatingConfigurationObserver, Regi
}
}
private IOException handleException(List<KeyValueScanner> instantiatedScanners,
Throwable t) {
// remove scaner read point before throw the exception
scannerReadPoints.remove(this);
if (storeHeap != null) {
storeHeap.close();
storeHeap = null;
if (joinedHeap != null) {
joinedHeap.close();
joinedHeap = null;
}
} else {
// close all already instantiated scanners before throwing the exception
for (KeyValueScanner scanner : instantiatedScanners) {
scanner.close();
}
}
return t instanceof IOException ? (IOException) t : new IOException(t);
}
@Override
public long getMaxResultSize() {
return maxResultSize;

View File

@ -378,18 +378,23 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
RegionScanner s = rsh.s;
LOG.info("Scanner " + this.scannerName + " lease expired on region "
+ s.getRegionInfo().getRegionNameAsString());
Region region = null;
try {
Region region = regionServer.getRegion(s.getRegionInfo().getRegionName());
region = regionServer.getRegion(s.getRegionInfo().getRegionName());
if (region != null && region.getCoprocessorHost() != null) {
region.getCoprocessorHost().preScannerClose(s);
}
} catch (IOException e) {
LOG.error("Closing scanner for " + s.getRegionInfo().getRegionNameAsString(), e);
} finally {
try {
s.close();
if (region != null && region.getCoprocessorHost() != null) {
region.getCoprocessorHost().postScannerClose(s);
}
} catch (IOException e) {
LOG.error("Closing scanner for "
+ s.getRegionInfo().getRegionNameAsString(), e);
LOG.error("Closing scanner for " + s.getRegionInfo().getRegionNameAsString(), e);
}
}
} else {
LOG.warn("Scanner " + this.scannerName + " lease expired, but no related" +