Sun Xin created HBASE-23376:
-------------------------------
Summary: 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
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)