Fix awaiting application finalizers to run on external interruption #9908
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.
/fixes #9901
It seems that #9827 introduced a bug where finalizers might not run in applications that are exited externally. I'll create a release straight after this PR is merged because this can be a relatively severe bug. This should revert the behaviour to what was in 2.1.17 but without the bug that was fixed (#9807)
One other thing is that this PR adds the
gracefulShutdownTimeoutmethod onZIOApp. This way users can configure how much time the runtime will wait before exiting after an external interruption signal is received. This is partially to mitigate issues where the app might hang on termination (e.g., #5185) or because of uninterruptible finalizers that never complete. I set the default value toDuration.Infinityin order to avoid breaking applications and to match the behaviour pre-2.1.17.I'll followup with:
ZIOAppgracefulShutdownTimeout