-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve shutdown logic #5514
Improve shutdown logic #5514
Conversation
Call close() instead of stop() on the event processor to make sure it has stopped using the subscription before removal. Otherwise errors may lead to stale subscriptions lingering.
At least in the case of the AzureSiriUpdater this leads to errors the second time. * Provide an alternative API for adding system shutdown hooks that takes a Runnable directly. * State the shutdown logic directly to the shutdown hook, remove the teardown method. * Handle the execute-hook-directly-if-shutting-down logic internally in ApplicationShutdownSupport.
This avoids running it twice on shutdown.
Notice that this adds immediate execution in the case that the JVM is already shutting down.
If the JVM is already shutting down, the graceful shutdown of the HTTP server should be executed immediately. Previously the server could potentially be started anyway.
If the JVM is already shutting down when the hook is scheduled, the message informing of this is logged immediately, previously it could potentially be lost.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #5514 +/- ##
==========================================
Coverage 66.91% 66.92%
+ Complexity 15691 15690 -1
==========================================
Files 1819 1819
Lines 70233 70228 -5
Branches 7392 7391 -1
==========================================
- Hits 46998 46997 -1
+ Misses 20777 20772 -5
- Partials 2458 2459 +1 ☔ View full report in Codecov by Sentry. |
This makes the shutdown logic much simpler. |
Skane will test this on their test/prod environements and report back. |
Nice! I like it :-) |
The code is from 2013, are someone using this? |
Personally, I do not know of anyone. I'd also like to tag @skinkie for completeness sake. |
@sven4all is Moop using this interface? It was used before. |
This is ready to merge. |
Summary
Details on the implementation and answers to questions that may arise while reading it
teardown()
was called on each updater in a simple loop.GraphUpdaterManager
calling teardown() as part of the normal shutdown process.GraphUpdaterManager
loop is done synchronously, this may delay the shutdown.Bonus question:
Unit tests
This is mostly untestable (for once).