callbacks registered to Log4jShutdown is not executed when stop is called#2133
callbacks registered to Log4jShutdown is not executed when stop is called#2133navis merged 1 commit intoapache:masterfrom
Conversation
|
Why do you say it is not? |
There was a problem hiding this comment.
IMHO this is more appropriately solved by metamx/java-util#28
There was a problem hiding this comment.
I am not opposed to the changes in this file though, as it adds better future proofing of the shutdown process for peons
|
oh I see now. ha! yeah, that needs fixed. |
There was a problem hiding this comment.
Ran into a spark bug a few days ago where a shutdown hook firing during a "clean" shutdown causes problems. This method actually needs synchronized or else a shutdown hook fired from a SIGTERM won't wait for runCallbacks() to finish
There was a problem hiding this comment.
Note that https://github.com/metamx/java-util/blob/master/src/main/java/com/metamx/common/lifecycle/Lifecycle.java#L267 does synchronize, so it may be sufficient to simply state in a comment on the stop method that synchronization is assumed to be performed in the caller
|
Looks good to me! Thanks for the catch. All my comments are minor and I'm fine if it goes in as is 👍 |
|
@drcrallen Revised concurrent stop threads to wait completion of shutdown process. Is this better? |
3480641 to
20d501a
Compare
There was a problem hiding this comment.
Can you put a sane timeout on here? like maybe 1 minute or something?
20d501a to
be56614
Compare
There was a problem hiding this comment.
is there a race here ? by the time waitTransition is called the state can be already stopped ?
There was a problem hiding this comment.
nm, I see the method waitTransition returns true if the current state is stopped.
be56614 to
5f34f63
Compare
|
met #2128. running test again |
There was a problem hiding this comment.
Since this is using Thread now, can this simply call hook.run()?
There was a problem hiding this comment.
Could be. But if lifecycle.start is called once, should we be expected to call lifecycle.stop?
There was a problem hiding this comment.
Yes, hook.run() should call its Runnable.run() which calls lifecycle.stop().
But in the interest of minimizing changes for this PR such a change can be ignored for now.
|
👍 after travis |
5f34f63 to
443ce2d
Compare
callbacks registered to Log4jShutdown is not executed when stop is called
ShutdownCallbackRegistry#addShutdownCallbackis expected to registercallback to be executed upon shutdown. But in Log4jShutdown, it's not.