Skip to content

callbacks registered to Log4jShutdown is not executed when stop is called#2133

Merged
navis merged 1 commit intoapache:masterfrom
navis:log4j-shudown-callback
Jan 15, 2016
Merged

callbacks registered to Log4jShutdown is not executed when stop is called#2133
navis merged 1 commit intoapache:masterfrom
navis:log4j-shudown-callback

Conversation

@navis
Copy link
Copy Markdown
Contributor

@navis navis commented Dec 21, 2015

ShutdownCallbackRegistry#addShutdownCallback is expected to register callback to be executed upon shutdown. But in Log4jShutdown, it's not.

@drcrallen
Copy link
Copy Markdown
Contributor

Why do you say it is not?

@drcrallen
Copy link
Copy Markdown
Contributor

I ask because of
#2124
#2123
#2122
being due to lifecycle.stop() not being able to be called multiple times without errors

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO this is more appropriately solved by metamx/java-util#28

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not opposed to the changes in this file though, as it adds better future proofing of the shutdown process for peons

@drcrallen
Copy link
Copy Markdown
Contributor

oh I see now. ha! yeah, that needs fixed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@drcrallen
Copy link
Copy Markdown
Contributor

Looks good to me! Thanks for the catch. All my comments are minor and I'm fine if it goes in as is 👍

@navis
Copy link
Copy Markdown
Contributor Author

navis commented Dec 22, 2015

@drcrallen Revised concurrent stop threads to wait completion of shutdown process. Is this better?

@navis navis force-pushed the log4j-shudown-callback branch from 3480641 to 20d501a Compare December 22, 2015 01:02
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put a sane timeout on here? like maybe 1 minute or something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@navis navis force-pushed the log4j-shudown-callback branch from 20d501a to be56614 Compare December 22, 2015 04:18
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a race here ? by the time waitTransition is called the state can be already stopped ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nm, I see the method waitTransition returns true if the current state is stopped.

@navis navis force-pushed the log4j-shudown-callback branch from be56614 to 5f34f63 Compare December 23, 2015 04:44
@navis
Copy link
Copy Markdown
Contributor Author

navis commented Dec 23, 2015

met #2128. running test again

@navis navis closed this Dec 23, 2015
@navis navis reopened this Dec 23, 2015
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is using Thread now, can this simply call hook.run()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be. But if lifecycle.start is called once, should we be expected to call lifecycle.stop?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@drcrallen
Copy link
Copy Markdown
Contributor

👍 after travis

@navis navis force-pushed the log4j-shudown-callback branch from 5f34f63 to 443ce2d Compare January 4, 2016 23:38
navis added a commit that referenced this pull request Jan 15, 2016
callbacks registered to Log4jShutdown is not executed when stop is called
@navis navis merged commit e4d15f3 into apache:master Jan 15, 2016
@navis navis deleted the log4j-shudown-callback branch January 15, 2016 12:28
@fjy fjy modified the milestone: 0.9.0 Feb 4, 2016
seoeun25 pushed a commit to seoeun25/incubator-druid that referenced this pull request Jan 10, 2020
seoeun25 pushed a commit to seoeun25/incubator-druid that referenced this pull request Jan 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants