Fix channel crash when cancelling then consuming using the same consumer tag and channel #5944
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.
This fixes a bug where the cancellation of a consumer then a subsequent consume with the same consumer tags whilst there are still messages in flight from the previous "incarnation" of the consumer would cause the channel to crash.
The reason for this was that the subsequent delivery would have an unexpected (for a new consumer) message id which would cause the channel to trigger the code paths it executes if a delivery got lost between the queue and the channel. This is extremely rare given most queue deliveries are done from the local node.
Triggering this code cause another bug where fetching messages would no longer work since 3.10 when messages stopped ever being kept in memory.
This PR fixes both bugs.
NB: it may seem like we are modifying the
rabbit_fifo:apply/3function without incrementing the machine version. We are but we are only modifying the Reply of the checkout command, not the actual state of the queue itself so this does not invalidate determinism. The current code never relies on the return value of this operation so this is safe to change as we also handle the old reply format.Fixes #5927