fix: suppress dead-letter logging during a terminating shutdown when disabled (#3256)#3262
Open
He-Pin wants to merge 1 commit into
Open
fix: suppress dead-letter logging during a terminating shutdown when disabled (#3256)#3262He-Pin wants to merge 1 commit into
He-Pin wants to merge 1 commit into
Conversation
ce0dc5a to
164b485
Compare
…disabled Motivation: With pekko.log-dead-letters-during-shutdown = off (the default), dead letters were still logged during the entire CoordinatedShutdown sequence. The DeadLetterListener had no shutdown awareness and was only stopped at the very end of shutdown (finalTerminate), so dead letters produced while the system was terminating - potentially for the whole shutdown duration - were logged unconditionally. Modification: - DeadLetterListener now suppresses logging while a coordinated shutdown that actually terminates this ActorSystem is in progress, when log-dead-letters-during-shutdown is disabled. Whether the shutdown terminates the system is taken from the EFFECTIVE per-reason configuration (CoordinatedShutdown.confWithOverrides), the same resolution CoordinatedShutdown uses, so a non-terminating run - including one where only a specific shutdown reason overrides terminate-actor-system to off - keeps logging enabled instead of silently disabling it for the rest of a still-running system's life. The CoordinatedShutdown extension reference is cached and the effective decision is computed at most once to keep the dead-letter path cheap. Result: Dead letters are no longer logged during a terminating shutdown when log-dead-letters-during-shutdown = off, while logging continues normally for a non-terminating coordinated shutdown (globally or per reason) and during normal operation. Tests: - actor-tests/testOnly org.apache.pekko.event.DeadLetterListenerShutdownSpec (plus DeadLetterSupressionSpec, DeadLetterSuspensionSpec) - all passed. Added directional tests that fail before the fix: a terminating shutdown that must suppress, and non-terminating shutdowns (global and per-reason override) that must keep logging. - actor/mimaReportBinaryIssues - no binary issues. References: Fixes #3256
164b485 to
1cdc7a9
Compare
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.
Motivation
When
pekko.log-dead-letters-during-shutdown = off(which is the default,reference.conf:63), dead letters were still logged throughout the entireCoordinatedShutdownsequence.DeadLetterListenerhad no shutdown awarenessand was only stopped at the very end of shutdown (
finalTerminate), so everydead letter produced while the system was terminating — potentially for the
whole (and sometimes lengthy) shutdown — was logged unconditionally. The
setting was effectively ignored until the very last moment.
Fixes #3256.
Modification
DeadLetterListenernow suppresses dead-letter logging while a coordinatedshutdown that actually terminates this
ActorSystemis in progress, whenlog-dead-letters-during-shutdownis disabled.Crucially, whether the shutdown terminates the system is taken from the
effective per-reason configuration, using the exact same resolution that
CoordinatedShutdownitself uses(
CoordinatedShutdown.confWithOverrides(conf, shutdownReason()).getBoolean("terminate-actor-system")).This matters because
terminate-actor-systemcan be overridden per shutdownreason. A coordinated shutdown that does not terminate the system (globally
via
terminate-actor-system = off, or only for a specific reason viareason-overrides) leaves a shutdown reason set on a still-running system —that must not suppress logging, otherwise dead-letter logging would be
silently disabled for the remaining lifetime of the running system.
The
CoordinatedShutdownextension reference is cached and the effectivedecision is memoized (computed at most once — the shutdown reason is set once
and never changes), so the per-dead-letter path stays allocation-free and cheap
(a volatile read of the shutdown reason during normal operation, no extension
lookup).
Result
log-dead-letters-during-shutdown = off— the setting is now honored for thewhole shutdown, not just after the listener is finally stopped.
(globally or per shutdown reason) and during normal operation.
private; no public API or binary-compatibilitychange —
actor / mimaReportBinaryIssuesis clean.Tests
sbt "actor-tests/testOnly org.apache.pekko.event.DeadLetterListenerShutdownSpec"→ 4 passed, plus
DeadLetterSupressionSpecandDeadLetterSuspensionSpec(no regression).
CoordinatedShutdownphase keeps thelistener alive mid-shutdown) that fail before the fix:
terminate-actor-system = off) must keeplogging;
(this one fails against an earlier base-setting-only gate);
sbt "actor/mimaReportBinaryIssues"→ no binary issues.References
Fixes #3256
This is an original contribution to Apache Pekko, made under the Apache License
2.0 (i.e. the changes are now Apache licensed). No third-party or Akka-derived
code is included.