HBASE-23155 May NPE when concurrent AsyncNonMetaRegionLocator#updateCachedLocationOnError (#718)
This commit is contained in:
parent
6aec958d66
commit
7924ba39e7
|
@ -570,6 +570,9 @@ class AsyncNonMetaRegionLocator {
|
|||
byte[] startKey = loc.getRegion().getStartKey();
|
||||
for (;;) {
|
||||
RegionLocations oldLocs = tableCache.cache.get(startKey);
|
||||
if (oldLocs == null) {
|
||||
return;
|
||||
}
|
||||
HRegionLocation oldLoc = oldLocs.getRegionLocation(loc.getRegion().getReplicaId());
|
||||
if (!canUpdateOnError(loc, oldLoc)) {
|
||||
return;
|
||||
|
|
|
@ -399,4 +399,14 @@ public class TestAsyncNonMetaRegionLocator {
|
|||
assertArrayEquals(loc.getRegion().getStartKey(), EMPTY_START_ROW);
|
||||
assertArrayEquals(loc.getRegion().getEndKey(), EMPTY_END_ROW);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConcurrentUpdateCachedLocationOnError() throws Exception {
|
||||
createSingleRegionTable();
|
||||
HRegionLocation loc =
|
||||
getDefaultRegionLocation(TABLE_NAME, EMPTY_START_ROW, RegionLocateType.CURRENT, false)
|
||||
.get();
|
||||
IntStream.range(0, 100).parallel()
|
||||
.forEach(i -> LOCATOR.updateCachedLocationOnError(loc, new NotServingRegionException()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue