Skip to content

log-dead-letters-during-shutdown=off not respected during CoordinatedShutdown #3256

Description

@He-Pin

Motivation

When log-dead-letters-during-shutdown = off, dead letters are still logged throughout the entire CoordinatedShutdown process. The DeadLetterListener is only stopped at the very end in finalTerminate(), but during all shutdown phases (potentially seconds to minutes), it remains active and logs unconditionally.

Current Behavior

Shutdown sequence (ActorSystem.scala:1110-1138):

  1. Line 1111: terminating = true — set immediately
  2. Line 1120: CoordinatedShutdown(this).run(...) — runs all shutdown phases
  3. During all phases: actors stop, messages become dead letters, DeadLetterListener is still subscribed and logging
  4. Phase actor-system-terminate: finally calls finalTerminate()
  5. Line 1136: listener stopped — only now, at the very tail end

DeadLetterListener has no shutdown awareness (DeadLetterListener.scala:73-79):

private def receiveWithAlwaysLogging: Receive = {
  case d: AllDeadLetters =>
    if (!isWrappedSuppressed(d)) {
      incrementCount()
      logDeadLetter(d, doneMsg = "")
    }
}

No check for isTerminating() or the LogDeadLettersDuringShutdown setting. All receive variants log unconditionally until the actor is stopped.

Expected Behavior

The DeadLetterListener should check context.system.isTerminating() (which returns true from the moment terminate() is called) and suppress logging when LogDeadLettersDuringShutdown = off, throughout the entire shutdown process — not just after finalTerminate.

Environment

  • Pekko Actor (any version)
  • ActorSystem.scala:1133-1138, DeadLetterListener.scala:73-79

References

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions