Skip to content

Conversation

@dumbbell
Copy link
Collaborator

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.

@dumbbell dumbbell added this to the 4.3.0 milestone Oct 23, 2025
@dumbbell dumbbell requested a review from ansd October 23, 2025 16:24
@dumbbell dumbbell self-assigned this Oct 23, 2025
@dumbbell dumbbell force-pushed the fix-reentrant-rabbit_logger_exchange_h branch from 5ef0e1c to 7ae2236 Compare October 23, 2025 16:50
[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.
[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.
@dumbbell dumbbell force-pushed the fix-reentrant-rabbit_logger_exchange_h branch from 7ae2236 to 73a41cc Compare October 23, 2025 17:28
@dumbbell dumbbell marked this pull request as ready for review October 23, 2025 17:58
@michaelklishin michaelklishin merged commit 05d1eca into main Oct 23, 2025
576 of 577 checks passed
@michaelklishin michaelklishin deleted the fix-reentrant-rabbit_logger_exchange_h branch October 23, 2025 18:47
michaelklishin added a commit that referenced this pull request Oct 23, 2025
rabbit_logger_exchange_h: Do not re-enter itself (backport #14796)
ansd added a commit that referenced this pull request Oct 24, 2025
ansd added a commit that referenced this pull request Oct 24, 2025
(cherry picked from commit edc5f43)
ansd added a commit that referenced this pull request Oct 24, 2025
(cherry picked from commit edc5f43)
(cherry picked from commit f9358588406b04ec5feeabe7539f55b616e7769e)
michaelklishin added a commit that referenced this pull request Oct 31, 2025
For 4.1.6: rabbit_logger_exchange_h: Do not re-enter itself (backport #14796) (backport #14804)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants