Skip to content

[Messenger] Potential PRECONDITION_FAILED error when using heartbeat with amqp-messenger #49029

@Jontsa

Description

@Jontsa

Symfony version(s) affected

6.1.7

Description

Since we upgraded to symfony/amqp-messenger 6.2.0, we noticed that our message consumer started failing randomly with error Server channel error: 406, message: PRECONDITION_FAILED - unknown delivery tag 1. The error suggests that transport is trying to ACK message on a wrong channel.

See RabbitMQ documentation and Stackoverflow

I was able to reproduce the error and looks like it is caused by PR #47831. If:

  • you have configured heartbeat for the connection
  • you are using messenger retry strategy and delay queues
  • message is picked up just before channel would reconnect
  • message handling takes few seconds and then fails

Transport will then dispatch message to delay queue but first it reconnects. When the original message is then ACK'd, the delivery tag is no longer valid.

Downgrading symfony/amqp-messenger to 6.1.3 fixes the issue.

How to reproduce

Error can be reproduced using https://github.com/Jontsa/symfony_amqp_issue

This project sets up rabbitmq and messenger with retry strategy. Use the included command to dispatch some messages to queue and then run messenger:consume. The message handler simulates a short delay in such way that when last message fails, the transport reconnects when sending message to delay queue. ACK will then fail because of this.

Possible Solution

No response

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions