Description
The conclusion of the discussion in #10661 is that the Consul peer discovery backend broke in RabbitMQ 3.13.0, following the rewrite of peer discovery in #9797. In this rewrite, the behavior changed significantly. In particular, the lock is only acquired after the discovery phase and only if the node executing peer discovery must join another node.
This breaks the Consul peer discovery backend because the lock also opened a Consul session. Discoverable nodes are those that have a session open.
This was ok in RabbitMQ 3.12.x and before because the steps were:
- acquire a lock (which implicitly opens a session in the Consul backend)
- discover nodes
- join nodes
- release the lock
In RabbitMQ 3.13.0, the behavior is:
- discover nodes; because nodes may not have opened a session yet, the discovery step can return nothing useful
- acquire a lock if the node should join another one; that's where the session is opened but the discovery step above likely returned nothing
- join nodes
- release the lock
While looking at this, I see that the session is never explicitly closed. Another thing to fix, once I know how to improve peer discovery to allow the Consul backend to open a session early, separate from the locking.