HBASE-29555 TestRollbackSCP.testFailAndRollback fails sometimes because non empty Scheduler queue
Summary
TestRollbackSCP.testFailAndRollback is flaky: it intermittently fails with
java.lang.IllegalArgumentException: scheduler queue not empty from
ProcedureExecutor.load() while restarting the master procedure executor.
The test restarts the ProcedureExecutor in place, reusing the same
executor and MasterProcedureScheduler instances to simulate a failover. While
the executor is being reloaded, other still-running threads of the live
mini-cluster master can push a procedure back into the shared scheduler in the
small window between scheduler.clear() and ProcedureExecutor.load()'s
Preconditions.checkArgument(scheduler.size() == 0, ...).
Two producers were identified:
- the
asyncTaskExecutorcallback that wakes a procedure after an async meta update (e.g.AssignmentManager.persistToMeta), and - an incoming
reportRegionStateTransitionRPC from a live region server, handled on anRpcServerhandler thread, which wakes a procedure throughProcedureEvent.wake->scheduler.addFront.
This is a test-infrastructure issue: a real master failover starts a fresh
process with a fresh executor/scheduler, so the production load() precondition
is not affected. The fix is therefore confined to test code.
Changes (ProcedureTestingUtility.restart(), test-only)
- Wait for the already shut-down
asyncTaskExecutorto fully terminate before clearing the scheduler, so any pending async wake-up callback has finished (closes the dominant, async producer deterministically). - Reload (
clear->procStore.start->init) in a bounded retry loop, retrying only whenload()fails specifically withscheduler queue not empty.ProcedureExecutor.stop()is explicitly safe to call after a failedinit(), so this is a clean redo and is robust to any external producer.
Test plan
- [x] Ran
TestRollbackSCP100x consecutively with the fix: 100/100 passed (twice). - [x] Control: reverted the fix and reran: reproduced the failure within a few iterations.
- [x] Regression: ran affected
hbase-proceduretests and a representativehbase-serversubset (TestSCP, TestProcedureAdmin, TestTransitRegionStateProcedure, TestCreateTableProcedure): all pass.
I prefer we just change the code the TestRollbackSCP.
We have lots of other tests which rely on this restart, changing the logic may hide some other bugs we want to expose in these tests.
Thanks.
I prefer we just change the code the TestRollbackSCP.
We have lots of other tests which rely on this restart, changing the logic may hide some other bugs we want to expose in these tests.
Thanks.
@Apache9 Yes, I am checking if we have missed any condition to stimulate the real production restart of master due to which this issue is happening only in the test. Please allow me sometime to make the necessary changes.