Link shutdown routine and sigterm handler to main thread#5555
Merged
cognifloyd merged 2 commits intoStackStorm:masterfrom Feb 2, 2022
Merged
Link shutdown routine and sigterm handler to main thread#5555cognifloyd merged 2 commits intoStackStorm:masterfrom
cognifloyd merged 2 commits intoStackStorm:masterfrom
Conversation
cognifloyd
approved these changes
Jan 26, 2022
Member
cognifloyd
left a comment
There was a problem hiding this comment.
Wow. That's obscure. Nice catch!
1bb7069 to
2077e93
Compare
arm4b
reviewed
Feb 2, 2022
Member
arm4b
left a comment
There was a problem hiding this comment.
Good stuff!
@khushboobhatia01 @cognifloyd the PR is just missing a Changelog here, which is an important ledger for the community to navigate the fixes and changes.
Could you folks please add the missing Changelog in a subsequent PR?
Contributor
Author
@armab Yes, I'll add it. |
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.
Currently when a SIGTERM signal is received by worker or workflow engine, sigterm handler runs in a new thread. Sigterm handler throws SystemExit exception which should be caught in the main thread for shutdown routine to be executed.
(https://github.com/StackStorm/st2/blob/master/st2actions/st2actions/cmd/actionrunner.py#L74 https://github.com/StackStorm/st2/blob/master/st2actions/st2actions/cmd/workflow_engine.py#L75)
However the above expected behaviour doesn't happen always. When we have other green threads processing messages SystemExit exception can be caught by these thread. And if the try-except block doesn't re-raise the exception, the shutdown routine is never executed.
This PR will take care of raising the exception in main thread, so that it can be caught and shutdown routine can complete properly. Ref https://eventlet.net/doc/modules/greenthread.html#eventlet.greenthread.GreenThread.kill
Issues seen locally when multiple executions are being processed.