Skip to content

Commit 21c1dc7

Browse files
committed
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 <stack@apache.com> (cherry picked from commit 2126ec9)
1 parent 0c5c0e5 commit 21c1dc7

3 files changed

Lines changed: 31 additions & 4 deletions

File tree

dev-support/spotbugs-exclude.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,4 +252,23 @@
252252
<Bug pattern="SC_START_IN_CTOR"/>
253253
</Match>
254254

255+
<Match>
256+
<!--
257+
False positives, NettyRpcServer#start & SimpleRpcServer#start are already synchronized and
258+
there is check to ensure single initialization of authTokenSecretMgr field.
259+
Ignore the warning, see HBASE-25875.
260+
!-->
261+
<Or>
262+
<And>
263+
<Class name="org.apache.hadoop.hbase.ipc.NettyRpcServer"/>
264+
<Method name="start"/>
265+
</And>
266+
<And>
267+
<Class name="org.apache.hadoop.hbase.ipc.SimpleRpcServer"/>
268+
<Method name="start"/>
269+
</And>
270+
</Or>
271+
<Bug pattern="ML_SYNC_ON_UPDATED_FIELD"/>
272+
</Match>
273+
255274
</FindBugsFilter>

hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcServer.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,12 @@ public synchronized void start() {
136136
}
137137
authTokenSecretMgr = createSecretManager();
138138
if (authTokenSecretMgr != null) {
139-
setSecretManager(authTokenSecretMgr);
140-
authTokenSecretMgr.start();
139+
// Start AuthenticationTokenSecretManager in synchronized way to avoid race conditions in
140+
// LeaderElector start. See HBASE-25875
141+
synchronized (authTokenSecretMgr) {
142+
setSecretManager(authTokenSecretMgr);
143+
authTokenSecretMgr.start();
144+
}
141145
}
142146
this.authManager = new ServiceAuthorizationManager();
143147
HBasePolicyProvider.init(conf, authManager);

hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/SimpleRpcServer.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,12 @@ public synchronized void start() {
423423
}
424424
authTokenSecretMgr = createSecretManager();
425425
if (authTokenSecretMgr != null) {
426-
setSecretManager(authTokenSecretMgr);
427-
authTokenSecretMgr.start();
426+
// Start AuthenticationTokenSecretManager in synchronized way to avoid race conditions in
427+
// LeaderElector start. See HBASE-25875
428+
synchronized (authTokenSecretMgr) {
429+
setSecretManager(authTokenSecretMgr);
430+
authTokenSecretMgr.start();
431+
}
428432
}
429433
this.authManager = new ServiceAuthorizationManager();
430434
HBasePolicyProvider.init(conf, authManager);

0 commit comments

Comments
 (0)