[Fix-18222][JdbcRegistry] Reuse a singleton scheduler executor in JdbcRegistryThreadFactory#18223
Merged
ruanwenjun merged 2 commits intoMay 10, 2026
Conversation
2413c5c to
7cf643f
Compare
8d5fb82 to
5da87f9
Compare
beb7f64 to
735ea25
Compare
SbloodyS
approved these changes
May 10, 2026
db50685 to
70cc7ec
Compare
…cRegistryThreadFactory JdbcRegistryThreadFactory#getDefaultSchedulerThreadExecutor returned a freshly created ScheduledExecutorService on every call, so the four scheduleWithFixedDelay sites in JdbcRegistryServer#start and JdbcRegistryDataManager#start each ran on their own pool, while the shutdown/shutdownNow calls in JdbcRegistry#close and JdbcRegistryServer#close closed yet another empty pool instead of the running ones. Daemon threads kept this from leaking on JVM exit, but the logic was inconsistent and the process held 4x the configured scheduled threads. Cache the executor as a lazy singleton (double-checked locking with volatile) so all callers share one pool and the close calls land on the actually-running pool.
…er instance The JdbcRegistryThreadFactory class held a JVM-global singleton scheduled executor. Multiple JdbcRegistryServer instances (tests, embedded StandaloneServer) shared the same pool, blurring lifecycle ownership and forcing JdbcRegistry#close() to shutdownNow() on a pool that other instances might still be using. Move the executor onto JdbcRegistryServer as an instance field, inject it into JdbcRegistryDataManager via the constructor, and shut it down in JdbcRegistryServer#close(). The state-guard at the top of the periodic tasks short-circuits any task that observes STOPPED, so a graceful shutdown() — combined with daemon threads — is enough to stop the JVM stalling. Delete the now-unused JdbcRegistryThreadFactory class and its test; the test only covered JDK ScheduledExecutorService basics and the static singleton identity that no longer exists.
70cc7ec to
4d7c498
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Was this PR generated or assisted by AI?
YES, ops 4.7
Purpose of the pull request
close #18222
Brief change log
Verify this pull request
This pull request is code cleanup without any test coverage.
(or)
This pull request is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(or)
Pull Request Notice
Pull Request Notice
If your pull request contains incompatible change, you should also add it to
docs/docs/en/guide/upgrade/incompatible.md