Skip to content

Commit 428afa9

Browse files
Bahram Chehrazysershe-apache
authored andcommitted
HBASE-22150 rssStub in HRegionServer is not thread safe and should not directly be used
Signed-off-by: Sergey Shelukhin <sershe@apache.org>
1 parent 8ec93ea commit 428afa9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2431,12 +2431,13 @@ public void abort(String reason, Throwable cause) {
24312431
msg += "\nCause:\n" + Throwables.getStackTraceAsString(cause);
24322432
}
24332433
// Report to the master but only if we have already registered with the master.
2434-
if (rssStub != null && this.serverName != null) {
2434+
RegionServerStatusService.BlockingInterface rss = rssStub;
2435+
if (rss != null && this.serverName != null) {
24352436
ReportRSFatalErrorRequest.Builder builder =
24362437
ReportRSFatalErrorRequest.newBuilder();
24372438
builder.setServer(ProtobufUtil.toServerName(this.serverName));
24382439
builder.setErrorMessage(msg);
2439-
rssStub.reportRSFatalError(null, builder.build());
2440+
rss.reportRSFatalError(null, builder.build());
24402441
}
24412442
} catch (Throwable t) {
24422443
LOG.warn("Unable to report fatal error to master", t);
@@ -2645,7 +2646,8 @@ private boolean keepLooping() {
26452646
private RegionServerStartupResponse reportForDuty() throws IOException {
26462647
if (this.masterless) return RegionServerStartupResponse.getDefaultInstance();
26472648
ServerName masterServerName = createRegionServerStatusStub(true);
2648-
if (masterServerName == null) return null;
2649+
RegionServerStatusService.BlockingInterface rss = rssStub;
2650+
if (masterServerName == null || rss == null) return null;
26492651
RegionServerStartupResponse result = null;
26502652
try {
26512653
rpcServices.requestCount.reset();
@@ -2664,7 +2666,7 @@ private RegionServerStartupResponse reportForDuty() throws IOException {
26642666
request.setPort(port);
26652667
request.setServerStartCode(this.startcode);
26662668
request.setServerCurrentTime(now);
2667-
result = this.rssStub.regionServerStartup(null, request.build());
2669+
result = rss.regionServerStartup(null, request.build());
26682670
} catch (ServiceException se) {
26692671
IOException ioe = ProtobufUtil.getRemoteException(se);
26702672
if (ioe instanceof ClockOutOfSyncException) {

0 commit comments

Comments
 (0)