Skip to content

rabbit_logger_exchange_h: Do not re-enter itself#14796

Merged
michaelklishin merged 2 commits intomainfrom
fix-reentrant-rabbit_logger_exchange_h
Oct 23, 2025
Merged

rabbit_logger_exchange_h: Do not re-enter itself#14796
michaelklishin merged 2 commits intomainfrom
fix-reentrant-rabbit_logger_exchange_h

Conversation

@dumbbell
Copy link
Copy Markdown
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)
ansd added a commit that referenced this pull request Jan 18, 2026
Add a test enabling all stable feature flags with exchange logging enabled.

This is a more general test case for #11652
that should catch all future feature flag issues when `rabbit_ff_controller` publishes a message.

Relates
#11652
#14069
#14796
ansd added a commit that referenced this pull request Jan 18, 2026
Add a test enabling all stable feature flags with exchange logging enabled.

This is a more general test case for #11652
that should catch all future feature flag issues when `rabbit_ff_controller` publishes a message.

Relates
#11652
#14069
#14796
ansd added a commit that referenced this pull request Jan 18, 2026
Add a test enabling all stable feature flags with exchange logging enabled.

This is a more general test case for #11652
that should catch all future feature flag issues when `rabbit_ff_controller` publishes a message.

Relates
#11652
#14069
#14796
mergify bot pushed a commit that referenced this pull request Jan 19, 2026
Add a test enabling all stable feature flags with exchange logging enabled.

This is a more general test case for https://github.com/rabbitmq/rabbitmq-server/discussions/11652
that should catch all future feature flag issues when `rabbit_ff_controller` publishes a message.

Relates
https://github.com/rabbitmq/rabbitmq-server/discussions/11652
https://github.com/rabbitmq/rabbitmq-server/discussions/14069
#14796

(cherry picked from commit e50a6bf)
mergify bot pushed a commit that referenced this pull request Jan 19, 2026
Add a test enabling all stable feature flags with exchange logging enabled.

This is a more general test case for https://github.com/rabbitmq/rabbitmq-server/discussions/11652
that should catch all future feature flag issues when `rabbit_ff_controller` publishes a message.

Relates
https://github.com/rabbitmq/rabbitmq-server/discussions/11652
https://github.com/rabbitmq/rabbitmq-server/discussions/14069
#14796

(cherry picked from commit e50a6bf)
(cherry picked from commit 3c80272)
@michaelklishin
Copy link
Copy Markdown
Collaborator

FTR, this was backported to v4.1.x for 4.1.8 because it a relevant change for those upgrading to 4.1 (let's not get into why some still upgrade to 4.1 when the same set of series can upgrade directly to 4.2).

michaelklishin pushed a commit that referenced this pull request Feb 24, 2026
Add a test enabling all stable feature flags with exchange logging enabled.

This is a more general test case for #11652
that should catch all future feature flag issues when `rabbit_ff_controller` publishes a message.

Relates
#11652
#14069
#14796
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.

3 participants