HBASE-23155 May NPE when concurrent AsyncNonMetaRegionLocator#updateCachedLocationOnError (#718)
This commit is contained in:
parent
44afe8cfde
commit
18ff188d9d
@ -570,6 +570,9 @@ class AsyncNonMetaRegionLocator {
|
|||||||
byte[] startKey = loc.getRegion().getStartKey();
|
byte[] startKey = loc.getRegion().getStartKey();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
RegionLocations oldLocs = tableCache.cache.get(startKey);
|
RegionLocations oldLocs = tableCache.cache.get(startKey);
|
||||||
|
if (oldLocs == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
HRegionLocation oldLoc = oldLocs.getRegionLocation(loc.getRegion().getReplicaId());
|
HRegionLocation oldLoc = oldLocs.getRegionLocation(loc.getRegion().getReplicaId());
|
||||||
if (!canUpdateOnError(loc, oldLoc)) {
|
if (!canUpdateOnError(loc, oldLoc)) {
|
||||||
return;
|
return;
|
||||||
|
@ -399,4 +399,14 @@ public class TestAsyncNonMetaRegionLocator {
|
|||||||
assertArrayEquals(loc.getRegion().getStartKey(), EMPTY_START_ROW);
|
assertArrayEquals(loc.getRegion().getStartKey(), EMPTY_START_ROW);
|
||||||
assertArrayEquals(loc.getRegion().getEndKey(), EMPTY_END_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…
x
Reference in New Issue
Block a user