You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by pa...@apache.org on 2021/05/17 06:52:48 UTC

[hbase] branch branch-2 updated: HBASE-25875 RegionServer failed to start with IllegalThreadStateException due to race condition in AuthenticationTokenSecretManager (#3250)

This is an automated email from the ASF dual-hosted git repository.

pankajkumar pushed a commit to branch branch-2
in repository https://gitbox.apache.org/repos/asf/hbase.git


The following commit(s) were added to refs/heads/branch-2 by this push:
     new 1a8d3c3  HBASE-25875 RegionServer failed to start with IllegalThreadStateException due to race condition in AuthenticationTokenSecretManager (#3250)
1a8d3c3 is described below

commit 1a8d3c3b6b71c6285a8b341e8b782d1e5a4db569
Author: Pankaj <pa...@apache.org>
AuthorDate: Mon May 17 12:17:24 2021 +0530

    HBASE-25875 RegionServer failed to start with IllegalThreadStateException due to race condition in AuthenticationTokenSecretManager (#3250)
    
    * HBASE-25875 RegionServer failed to start with IllegalThreadStateException due to race condition in AuthenticationTokenSecretManager's start & retrievePassword method
    
    Signed-off-by: stack <st...@apache.com>
    (cherry picked from commit 2126ec94f0032220fcccdca463f0f185e3653ace)
---
 dev-support/spotbugs-exclude.xml                      | 19 +++++++++++++++++++
 .../org/apache/hadoop/hbase/ipc/NettyRpcServer.java   |  8 ++++++--
 .../org/apache/hadoop/hbase/ipc/SimpleRpcServer.java  |  8 ++++++--
 3 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/dev-support/spotbugs-exclude.xml b/dev-support/spotbugs-exclude.xml
index 1137f5f..2f0684e 100644
--- a/dev-support/spotbugs-exclude.xml
+++ b/dev-support/spotbugs-exclude.xml
@@ -252,4 +252,23 @@
     <Bug pattern="SC_START_IN_CTOR"/>
   </Match>
 
+  <Match>
+    <!--
+      False positives, NettyRpcServer#start & SimpleRpcServer#start are already synchronized and
+      there is check to ensure single initialization of authTokenSecretMgr field.
+      Ignore the warning, see HBASE-25875.
+    !-->
+    <Or>
+      <And>
+        <Class name="org.apache.hadoop.hbase.ipc.NettyRpcServer"/>
+        <Method name="start"/>
+      </And>
+      <And>
+        <Class name="org.apache.hadoop.hbase.ipc.SimpleRpcServer"/>
+        <Method name="start"/>
+      </And>
+    </Or>
+    <Bug pattern="ML_SYNC_ON_UPDATED_FIELD"/>
+  </Match>
+
 </FindBugsFilter>
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcServer.java
index f34cad5..de958b8 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcServer.java
@@ -136,8 +136,12 @@ public class NettyRpcServer extends RpcServer {
     }
     authTokenSecretMgr = createSecretManager();
     if (authTokenSecretMgr != null) {
-      setSecretManager(authTokenSecretMgr);
-      authTokenSecretMgr.start();
+      // Start AuthenticationTokenSecretManager in synchronized way to avoid race conditions in
+      // LeaderElector start. See HBASE-25875
+      synchronized (authTokenSecretMgr) {
+        setSecretManager(authTokenSecretMgr);
+        authTokenSecretMgr.start();
+      }
     }
     this.authManager = new ServiceAuthorizationManager();
     HBasePolicyProvider.init(conf, authManager);
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcServer.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcServer.java
index cbcbc9a..7818572 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcServer.java
@@ -423,8 +423,12 @@ public class SimpleRpcServer extends RpcServer {
     }
     authTokenSecretMgr = createSecretManager();
     if (authTokenSecretMgr != null) {
-      setSecretManager(authTokenSecretMgr);
-      authTokenSecretMgr.start();
+      // Start AuthenticationTokenSecretManager in synchronized way to avoid race conditions in
+      // LeaderElector start. See HBASE-25875
+      synchronized (authTokenSecretMgr) {
+        setSecretManager(authTokenSecretMgr);
+        authTokenSecretMgr.start();
+      }
     }
     this.authManager = new ServiceAuthorizationManager();
     HBasePolicyProvider.init(conf, authManager);