From 2c07372c2f923cc8421045915773d33611ce28d8 Mon Sep 17 00:00:00 2001 From: Jimmy Xiang Date: Wed, 8 Oct 2014 18:22:33 -0700 Subject: [PATCH] HBASE-12209 NPE in HRegionServer#getLastSequenceId --- .../hadoop/hbase/regionserver/HRegionServer.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index f45f890dac9..7c1e805122b 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -2110,11 +2110,23 @@ public class HRegionServer extends HasThread implements try { GetLastFlushedSequenceIdRequest req = RequestConverter .buildGetLastFlushedSequenceIdRequest(region); - lastFlushedSequenceId = rssStub.getLastFlushedSequenceId(null, req) + RegionServerStatusService.BlockingInterface rss = rssStub; + if (rss == null) { // Try to connect one more time + createRegionServerStatusStub(); + rss = rssStub; + if (rss == null) { + // Still no luck, we tried + LOG.warn("Unable to connect to the master to check " + + "the last flushed sequence id"); + return -1l; + } + } + lastFlushedSequenceId = rss.getLastFlushedSequenceId(null, req) .getLastFlushedSequenceId(); } catch (ServiceException e) { lastFlushedSequenceId = -1l; - LOG.warn("Unable to connect to the master to check " + "the last flushed sequence id", e); + LOG.warn("Unable to connect to the master to check " + + "the last flushed sequence id", e); } return lastFlushedSequenceId; }