Description
Quorum queues have a resend and re-sequencing protocol in place to avoid messages sent to a QQ member that isn't leader anymore causing the channel -> queue publishing ordering guarantees to be violated.
This is implemented in the rabbit_fifo_client
and rabbit_fifo
modules but is probably more complicated than necessary.
Currently if a channels sends an enqueue command to a follower member the follower will reply with {rejected, not_leader, Leader}
and the channel will resend this message to the leader member instead. When a QQ member becomes leader it will also send a {leader_change, Leader}
message to all known channels (enqueuers and consumers). When they receive this message they will unconditionally resend all pending commands.
The rabbit_fifo
state machine will handle the re-sequencing state needed to handle the case where only a single message is resent. This means holding messages in memory per channel until the right sequence of message arrives creating a potential risk of memory issues.
The suggestion here is to stop re-sending individual messages when the channel receives {rejected, not_leader, Leader}
events and instead just resend all pending message when detecting the leader has changed and if detecting a gap in the committed correlation ids (increasing integer value that is used to line up message). If we do this we can stop keeping out of order messages in memory during re-sequencing and instead just return dropped
in the correlation response term so that rabbit_fifo_client does send a publisher confirm for the message.