SwaraliJoshi commented on code in PR #8357:
URL: https://github.com/apache/hbase/pull/8357#discussion_r3584727639
##########
hbase-server/src/test/java/org/apache/hadoop/hbase/master/assignment/TestRollbackSCP.java:
##########
@@ -160,6 +203,67 @@ public void describeTo(Description description) {
};
}
+ /**
+ * Wait for the (already shutdown) asyncTaskExecutor of the given executor
to fully terminate.
+ * HBASE-29555 (Gap #1): callbacks that wake a procedure after an async
operation (e.g.
+ * AssignmentManager#persistToMeta run on the executor's asyncTaskExecutor,
not on a
+ * PEWorker. In production a master restart is a fresh process, so no such
callback can survive
+ * into the reloaded executor. Here we reuse the same executor in-place, so
a pending callback can
+ * call scheduler.addFront during the reload. ProcedureExecutor shuts the
+ * asyncTaskExecutor down; waiting for it to terminate guarantees any
pending callback has run
+ * before we clear the scheduler, reproducing the "no async work survives
the restart" guarantee.
+ */
+ private static void awaitAsyncTaskExecutorTermination(ProcedureExecutor<?>
procExec) {
+ ExecutorService asyncTaskExecutor = procExec.getAsyncTaskExecutor();
+ if (asyncTaskExecutor == null) {
+ return;
+ }
+ long deadline = System.currentTimeMillis() + 60000;
+ try {
+ while (!asyncTaskExecutor.awaitTermination(1, TimeUnit.SECONDS)) {
Review Comment:
You are right, let me change it to 1 minute.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]