@@ -226,20 +226,32 @@ private Flow confirmOpened(MasterProcedureEnv env, RegionStateNode regionNode)
226
226
return Flow .HAS_MORE_STATE ;
227
227
}
228
228
229
- if (incrementAndCheckMaxAttempts (env , regionNode )) {
229
+ int retries = env .getAssignmentManager ().getRegionStates ().addToFailedOpen (regionNode )
230
+ .incrementAndGetRetries ();
231
+ int maxAttempts = env .getAssignmentManager ().getAssignMaxAttempts ();
232
+ LOG .info ("Retry={} of max={}; {}; {}" , retries , maxAttempts , this , regionNode .toShortString ());
233
+
234
+ if (retries >= maxAttempts ) {
230
235
env .getAssignmentManager ().regionFailedOpen (regionNode , true );
231
236
setFailure (getClass ().getSimpleName (), new RetriesExhaustedException (
232
237
"Max attempts " + env .getAssignmentManager ().getAssignMaxAttempts () + " exceeded" ));
233
238
regionNode .unsetProcedure (this );
234
239
return Flow .NO_MORE_STATE ;
235
240
}
241
+
236
242
env .getAssignmentManager ().regionFailedOpen (regionNode , false );
237
243
// we failed to assign the region, force a new plan
238
244
forceNewPlan = true ;
239
245
regionNode .setRegionLocation (null );
240
246
setNextState (RegionStateTransitionState .REGION_STATE_TRANSITION_GET_ASSIGN_CANDIDATE );
241
- // Here we do not throw exception because we want to the region to be online ASAP
242
- return Flow .HAS_MORE_STATE ;
247
+
248
+ if (retries > env .getAssignmentManager ().getFailedOpenAttempts ()) {
249
+ // Throw exception to backoff and retry when failed open too many times
250
+ throw new HBaseIOException ("Failed to open region" );
251
+ } else {
252
+ // Here we do not throw exception because we want to the region to be online ASAP
253
+ return Flow .HAS_MORE_STATE ;
254
+ }
243
255
}
244
256
245
257
private void closeRegion (MasterProcedureEnv env , RegionStateNode regionNode ) throws IOException {
@@ -400,14 +412,6 @@ void unattachRemoteProc(RegionRemoteProcedureBase proc) {
400
412
this .remoteProc = null ;
401
413
}
402
414
403
- private boolean incrementAndCheckMaxAttempts (MasterProcedureEnv env , RegionStateNode regionNode ) {
404
- int retries = env .getAssignmentManager ().getRegionStates ().addToFailedOpen (regionNode )
405
- .incrementAndGetRetries ();
406
- int max = env .getAssignmentManager ().getAssignMaxAttempts ();
407
- LOG .info ("Retry={} of max={}; {}; {}" , retries , max , this , regionNode .toShortString ());
408
- return retries >= max ;
409
- }
410
-
411
415
@ Override
412
416
protected void rollbackState (MasterProcedureEnv env , RegionStateTransitionState state )
413
417
throws IOException , InterruptedException {
0 commit comments