michaellx1057 commented on PR #18645: URL: https://github.com/apache/dolphinscheduler/pull/18645#issuecomment-5696147234
While checking the demotion and re-election path, I found a related lifecycle issue in the existing Master coordinators. `close()` interrupts the worker thread, but a database call may continue after interruption. A subsequent `start()` can reset the shared running flag and let the old polling loop continue alongside the new one. The exception → standby → retry path in this PR can exercise that sequence, so I have pushed a separate follow-up commit ([48f3e2a](https://github.com/apache/dolphinscheduler/pull/18645/commits/48f3e2a5b02a171f479fed8471a6c2da62349748)) rather than treating the role-transition tests as sufficient. The change keeps the existing dedicated-thread structure. Each run has its own stop flag. If the previous run is still finishing, `start()` records the restart request; the replacement starts after the previous run finishes its business work. A later `close()` cancels that request. This applies to both `WorkflowSerialCoordinator` and `TaskGroupCoordinator`, since the Master listener restarts both. The added tests use real coordinators with deliberately blocked DAO/handler calls, including repeated role changes through `MasterCoordinatorListener`. They check that the old run cannot resume polling, remaining canceled work is discarded, and shutdown cancels a pending restart. The original regression fails before the fix; the affected tests pass on JDK 8. This addresses overlap within the same coordinator instance. It does not cancel an already-issued database operation or provide fencing between different Masters. If the old database call never returns, its replacement remains pending rather than running concurrently. -- 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]
