Skip to content

Conversation

@mergify
Copy link

@mergify mergify bot commented Oct 23, 2025

Why

Publishing a log message to an exchange might trigger other messages to be logged. This caused two issues:

  1. the exchange logger re-entering itself in an infinite loop
  2. if the message is logged from a gen_server-like process, like a Ra server, that is involved in the publishing code path, the process might call itself, leading to a blocked situation

How

The first issue is fixed with a variable stored in the process dictionary by the log/2 function. This way, the function can check if it is called from itself because the first incantation stored a variable there.

The second issue is fixed by publishing the message asynchronously from a separate process. This is ok because we don't care if the publish was successful or not. We re-use the process that was started initially to declare the exchange.

Fixes #14069.


This is an automatic backport of pull request #14796 done by Mergify.
This is an automatic backport of pull request #14804 done by Mergify.

[Why]
Publishing a log message to an exchange might trigger other messages to
be logged. This caused two issues:
1. the exchange logger re-entering itself in an infinite loop
2. if the message is logged from a gen_server-like process, like a Ra
   server, that is involved in the publishing code path, the process
   might call itself, leading to a blocked situation

[How]
The first issue is fixed with a variable stored in the process
dictionary by the `log/2` function. This way, the function can check if
it is called from itself because the first incantation stored a variable
there.

The second issue is fixed by publishing the message asynchronously from
a separate process. This is ok because we don't care if the publish was
successful or not. We re-use the process that was started initially to
declare the exchange.

Fixes #14069.

(cherry picked from commit 7cc0aa9)
(cherry picked from commit 7d12e42)
[Why]
It makes debugging easier, especially now that this process does more
than the initial setup: it acts as the actual publisher of the log
messages.

(cherry picked from commit 73a41cc)
(cherry picked from commit ad5f47d)
@michaelklishin michaelklishin added this to the 4.1.6 milestone Oct 23, 2025
@michaelklishin michaelklishin changed the title rabbit_logger_exchange_h: Do not re-enter itself (backport #14796) (backport #14804) For 4.1.6: rabbit_logger_exchange_h: Do not re-enter itself (backport #14796) (backport #14804) Oct 23, 2025
(cherry picked from commit edc5f43)
(cherry picked from commit f9358588406b04ec5feeabe7539f55b616e7769e)
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.

4 participants