Repository navigation
YARN-12003. Shut down the Router scheduled executor on service stop - #8785
Conversation
c0ce1a1 to
b516741
Compare
|
💔 -1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
b516741 to
c79b87c
Compare
|
💔 -1 overall
This message was automatically generated. |
|
💔 -1 overall
This message was automatically generated. |
Router#serviceStart schedules SubClusterCleaner on scheduledExecutorService at a fixed rate, enabled by default (DEFAULT_ROUTER_DEREGISTER_SUBCLUSTER_ENABLED) with a 60s interval. serviceStop never shut that executor down, so the cleaner outlived the Router and kept calling FederationStateStoreFacade#getSubClusters and #deregisterSubCluster against a state store nothing was maintaining. Uses HadoopExecutors#shutdown - graceful shutdown, bounded wait, then force - rather than shutdownNow(), so an in-flight scan finishes before the store it is reading can be closed. It waits up to 5s for the executor to drain, then interrupts it and waits up to 5s more, so this adds at most 10s to stopping the Router. TestRouter covers it through a new @VisibleForTesting getter for the executor: once the Router has stopped, the executor is terminated. Split out of YARN-11984, whose federation mock Router closes the state store once the Router has stopped and so relies on the cleaner having stopped. Contains content generated by Claude Code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b94c91e to
7131c20
Compare
|
💔 -1 overall
This message was automatically generated. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🎊 +1 overall
This message was automatically generated. |
|
@slfan1989 This PR is CI green and Yetus green, and ready to review. |
slfan1989
left a comment
There was a problem hiding this comment.
LGTM.
One small, non-blocking suggestion: could you reword "it must not still be running once the Router has stopped" to describe the bounded shutdown?
HadoopExecutors.shutdown() may return after the timeout if a task does not respond to interruption.
For example:
// Shut down the executor before stopping child services, allowing an
// in-flight cleaner run to finish within the configured timeout.
…top. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks @slfan1989, reworded in b816940 to describe the bounded, best-effort shutdown. Could you re-review when you get a chance? The review is still marked "changes requested". |
|
🎊 +1 overall
This message was automatically generated. |
slfan1989
left a comment
There was a problem hiding this comment.
LGTM.
Thanks for updating the comment to accurately describe the bounded, best-effort shutdown. My previous concern has been addressed.
This PR is ready to merge from my side.
|
@joseluisll Thanks for the contribution! Merged into trunk. |
Depends on (has to be merged first):
clears a CI failure: it edits TestRouterWebServicesREST.java:719-742, where TestFederationWebApp fails at line 737 in this PR's precommit, still red in the latest run
Description of PR
JIRA: YARN-12003
Router#serviceStartschedulesSubClusterCleaneronscheduledExecutorServiceat a fixed rate. This is on by default (yarn.router.deregister.subcluster.enabled) and runs every 60s.Router#serviceStopnever shuts that executor down. As a result, the cleaner outlives the Router and keeps callingFederationStateStoreFacade#getSubClustersand#deregisterSubClusteron a state store that nothing maintains any more. Its thread is not a daemon thread, so it can also keep the JVM alive. This shows up when a Router is stopped inside a JVM that keeps running: tests, embedded or mock federation setups, or a stop/start in the same process.Changes:
Router#serviceStopnow callsHadoopExecutors#shutdown(scheduledExecutorService, LOG, 5, SECONDS)before stopping the child services. This is a graceful shutdown with a bounded wait. It waits up to 5s for an in-flight cleaner run to finish, then callsshutdownNow()and waits up to 5s more, so stopping the Router takes at most 10s longer. We don't callshutdownNow()straight away, so that a scan already in progress can finish before the state store it is reading is closed.HadoopExecutors#shutdowndoes nothing when the executor is null, so stopping a Router that was never initialised is still safe.@VisibleForTestinggetter,Router#getScheduledExecutorService().TestRouter#testServiceStopShutsDownScheduledExecutor.How was this patch tested?
TestRouteron Linux with JDK 21: 6/6 tests pass, including the newtestServiceStopShutsDownScheduledExecutor.HadoopExecutors.shutdowncall removed fromserviceStop, the new test fails withexpected: <true> but was: <false>. So the test does catch the missing shutdown.For code changes:
declared according to the connector-specific documentation? Note: Automated CI
testing doesn't cover all cases so manual testing with cloud storage is still
required.
LICENSE,LICENSE-binary,NOTICE-binaryfiles?AI Tooling
If an AI tool was used:
where is the name of the AI tool used.
https://www.apache.org/legal/generative-tooling.html
Contains content generated by Claude Code.