[
https://issues.apache.org/jira/browse/HBASE-23376?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16994605#comment-16994605
]
Sun Xin commented on HBASE-23376:
---------------------------------
[~stack] Thanks for reviewing. I'm afraid NPE will still happen if we can't
guarantee at least one RegionLocation in the locs. We can also avoid it by
judging whether the locs is empty.
> NPE happens while replica region is moving
> ------------------------------------------
>
> Key: HBASE-23376
> URL: https://issues.apache.org/jira/browse/HBASE-23376
> Project: HBase
> Issue Type: Bug
> Components: read replicas
> Reporter: Sun Xin
> Assignee: Sun Xin
> Priority: Minor
> Attachments: HBASE-23376.branch-2.001.patch,
> HBASE-23376.master.v02.dummy.patch, HBASE-23376.master.v02.dummy.patch
>
>
> The following code is from AsyncNonMetaRegionLocator#addToCache
> {code:java}
> private RegionLocations addToCache(TableCache tableCache, RegionLocations
> locs) {
> LOG.trace("Try adding {} to cache", locs);
> byte[] startKey = locs.getDefaultRegionLocation().getRegion().getStartKey();
> ...
> }{code}
> we will get a NPE if the locs is without the default region.
>
> The following code is from
> AsyncRegionLocatorHelper#updateCachedLocationOnError
> {code:java}
> ...
> if (cause instanceof RegionMovedException) {
> RegionMovedException rme = (RegionMovedException) cause;
> HRegionLocation newLoc =
> new HRegionLocation(loc.getRegion(), rme.getServerName(),
> rme.getLocationSeqNum());
> LOG.debug("Try updating {} with the new location {} constructed by {}",
> loc, newLoc,
> rme.toString());
> addToCache.accept(newLoc);
> ...{code}
> If the replica region is moving, we will get a RegionMovedException and add
> the HRegionLocation of replica region to cache. And finally NPE happens.
>
> {code:java}
> java.lang.NullPointerExceptionjava.lang.NullPointerException at
> org.apache.hadoop.hbase.client.AsyncNonMetaRegionLocator.addToCache(AsyncNonMetaRegionLocator.java:240)
> at
> org.apache.hadoop.hbase.client.AsyncNonMetaRegionLocator.addLocationToCache(AsyncNonMetaRegionLocator.java:596)
> at
> org.apache.hadoop.hbase.client.AsyncRegionLocatorHelper.updateCachedLocationOnError(AsyncRegionLocatorHelper.java:80)
> at
> org.apache.hadoop.hbase.client.AsyncNonMetaRegionLocator.updateCachedLocationOnError(AsyncNonMetaRegionLocator.java:610)
> at
> org.apache.hadoop.hbase.client.AsyncRegionLocator.updateCachedLocationOnError(AsyncRegionLocator.java:153)
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)