Skip to content

Replace the consumer channel when the server cancels a consumer - #432

Merged
michaelklishin merged 1 commit into
mainfrom
fix-cancelled-consumer-recovery
Aug 22, 2026
Merged

michaelklishin merged 1 commit into
mainfrom
fix-cancelled-consumer-recovery

Conversation

@eglitobias

@eglitobias eglitobias commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

On RabbitMQ 4.3 a quorum queue cancels a timed out consumer instead of closing the channel. Hutch re-subscribed on the same channel, which loses messages: the broker keeps routing deliveries to the cancelled tag, the client has already unregistered it, so Bunny drops the frame with no consumer for tag .... Those messages sit unacked under a consumer that no longer exists, and only closing the channel gets them back.

handle_cancellation now replaces the channel (close, reopen, re-declare the exchange) and re-subscribes every consumer. On its own thread, because closing the channel shuts down the work pool the callback runs on.

Reproduced with a quorum queue, x-consumer-timeout 5s, handler blocked 20s: four dropped deliveries per run before, none after. channel_recovery_spec.rb passed most of the time anyway, because the next timeout tick usually requeued them. Only 4.3 is affected, earlier versions close the channel themselves.

Also cut that spec's second wait_for from 90s to 15s.

@michaelklishin michaelklishin added this to the 2.0.0 milestone Aug 21, 2026
@eglitobias
eglitobias marked this pull request as draft August 21, 2026 08:22
@eglitobias
eglitobias force-pushed the fix-cancelled-consumer-recovery branch from 54695b3 to 77aa2e3 Compare August 21, 2026 08:23
@eglitobias
eglitobias marked this pull request as ready for review August 21, 2026 08:32
@michaelklishin

Copy link
Copy Markdown
Member

@eglitobias I have found a few more issues and known flaky test patterns, will push an update once I'm done with them

@michaelklishin
michaelklishin merged commit 80a0f84 into main Aug 22, 2026
34 of 36 checks passed
@michaelklishin
michaelklishin deleted the fix-cancelled-consumer-recovery branch August 22, 2026 02:44
@michaelklishin

Copy link
Copy Markdown
Member

I'll submit a follow-up PR.

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.

2 participants