Skip to content

Revert "perf: prioritize handling of Terminated after updating ddata" #32766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2025

Conversation

pvlugter
Copy link
Member

@pvlugter pvlugter commented Jul 27, 2025

Revert #32756.

Optimisation didn't end up prioritising the first Terminated message, as later stashed messages will be prepended on unstash.

But this also breaks the receive of that Terminated message — where it will be ignored on reprocessing, if it was received during update and handled specially without stash. Which means that the shard coordinator never removes the terminated shard region, and will continue to report that shards have their home on a terminated node.

Terminated messages are handled specially. They'll be removed from the terminatedQueued when received the first time:

protected def receivedTerminated(t: Terminated): Unit =
terminatedQueued.get(t.actor).foreach { optionalMessage =>
terminatedQueued -= t.actor // here we know that it is the SAME ref which was put in
optionalMessage match {
case Some(customTermination) =>
// needed for stashing of custom watch messages to work (or stash will stash the Terminated message instead)
currentMessage = currentMessage.copy(message = customTermination)
receiveMessage(customTermination)
case None =>
receiveMessage(t)
}
}

While the prepend on unstash ensures that it gets added back again:

/**
* Enqueues `envelope` at the first position in the mailbox. If the message contained in
* the envelope is a `Terminated` message, it will be ensured that it can be re-received
* by the actor.
*/
private def enqueueFirst(envelope: Envelope): Unit = {
mailbox.enqueueFirst(self, envelope)
envelope.message match {
case Terminated(ref) => actorCell.terminatedQueuedFor(ref, None)
case _ =>
}
}
}

So these specially handled Terminated messages were always being ignored.

@pvlugter pvlugter merged commit 98e667a into akka:main Jul 27, 2025
5 checks passed
@pvlugter pvlugter deleted the revert-shard-coordinator-terminated branch July 27, 2025 11:21
@sebastian-alfers sebastian-alfers added this to the 2.10.8 milestone Jul 27, 2025
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.

3 participants