Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-23155 May NPE when concurrent AsyncNonMetaRegionLocator#updateC… #718

Merged
merged 1 commit into from Oct 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -570,6 +570,9 @@ private void removeLocationFromCache(HRegionLocation loc) {
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;
Expand Down
Expand Up @@ -399,4 +399,14 @@ public void testLocateBeforeInOnlyRegion() throws IOException, InterruptedExcept
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()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If single-region table, will this produce a null RegionLocation? Should there be something going on in the background clearing tableCache?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updateCachedLocationOnError will produce a null RegionLocation.

.forEach(i -> LOCATOR.updateCachedLocationOnError(loc, new NotServingRegionException()));
}
}