Skip to content

For 4.2.4: rabbit_logger_exchange_h: Always declare exchange, even if exchange logging is disabled (backport #15320)#15331

Merged
michaelklishin merged 4 commits intov4.2.xfrom
mergify/bp/v4.2.x/pr-15320
Jan 22, 2026
Merged

For 4.2.4: rabbit_logger_exchange_h: Always declare exchange, even if exchange logging is disabled (backport #15320)#15331
michaelklishin merged 4 commits intov4.2.xfrom
mergify/bp/v4.2.x/pr-15320

Conversation

@mergify
Copy link
Copy Markdown

@mergify mergify bot commented Jan 21, 2026

Why

When the exchange logger handler is added, the broker is not ready to declare the exchange.

The previous implementation used a temporary process that entered a loop to wait for the broker to be ready and declare the exchange. It was possible that definitions were imported before the exchange was declared, leading to errors if bindings referenced it.

There was another problem: the exported definitions were dependent on the exchange logger configuration:

  • The default vhost under which the logger exchange is declared is configurable.
  • The logger exchange is only declared if the exchange logger handler is enabled in the configuration.

Because of this, the import of definitions could fail if the configuration of the node where the definitions are imported does not enable the exchange logger handler.

How

This patch changes two things:

  1. The logger exchange is always declared, regardless if exchange-based logging is enabled or not. This also allows to get rid of the polling in the setup process.

  2. The logger exchange is included in the exported definitions.

This way, the exported definitions don't depend on any configuration on the nodes they are imported in: the exported definitions are self-contained and know about this logger exchange.

Part 1 could be enough to fix the problem on RabbitMQ version that include this patch. Part 2 allows to fix the problem when definitions are exported from a version with this patch and are imported on a version without.


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

dumbbell and others added 2 commits January 21, 2026 23:37
…ogging is disabled

[Why]
When the exchange logger handler is added, the broker is not ready to
declare the exchange.

The previous implementation used a temporary process that entered a loop
to wait for the broker to be ready and declare the exchange. It was
possible that definitions were imported before the exchange was
declared, leading to errors if bindings referenced it.

There was another problem: the exported definitions were dependent on
the exchange logger configuration:
* The default vhost under which the logger exchange is declared is
  configurable.
* The logger exchange is only declared if the exchange logger handler is
  enabled in the configuration.

Because of this, the import of definitions could fail if the
configuration of the node where the definitions are imported does not
enable the exchange logger handler.

[How]
This patch changes two things:

1. The logger exchange is always declared, regardless if exchange-based
   logging is enabled or not. This also allows to get rid of the polling
   in the setup process.

2. The logger exchange is included in the exported definitions.

This way, the exported definitions don't depend on any configuration on
the nodes they are imported in: the exported definitions are
self-contained and know about this logger exchange.

Part 1 could be enough to fix the problem on RabbitMQ version that
include this patch. Part 2 allows to fix the problem when definitions
are exported from a version with this patch and are imported on a
version without.

V2: Ignore the failure to declare the exchange. It should probably not
    be the only logger configured because there is a chicken-and-egg
    loop with it. It should not block the broker from starting.
(cherry picked from commit a908504)

# Conflicts:
#	deps/rabbit/src/rabbit_logger_exchange_h.erl
(cherry picked from commit 0ec0df1)
@mergify mergify bot added the conflicts label Jan 21, 2026
@mergify
Copy link
Copy Markdown
Author

mergify bot commented Jan 21, 2026

Cherry-pick of a908504 has failed:

On branch mergify/bp/v4.2.x/pr-15320
Your branch is up to date with 'origin/v4.2.x'.

You are currently cherry-picking commit a908504c9.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   deps/rabbit/src/rabbit.erl
	modified:   deps/rabbit/src/rabbit_definitions.erl
	modified:   deps/rabbit/test/exchanges_SUITE.erl
	modified:   deps/rabbit/test/metadata_store_migration_SUITE.erl
	modified:   deps/rabbit/test/unit_connection_tracking_SUITE.erl

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   deps/rabbit/src/rabbit_logger_exchange_h.erl

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@michaelklishin michaelklishin changed the title rabbit_logger_exchange_h: Always declare exchange, even if exchange logging is disabled (backport #15320) For 4.2.4: rabbit_logger_exchange_h: Always declare exchange, even if exchange logging is disabled (backport #15320) Jan 21, 2026
@michaelklishin michaelklishin added this to the 4.2.4 milestone Jan 21, 2026
michaelklishin added a commit that referenced this pull request Jan 22, 2026
All of our efforts go into 'rabbitmqadmin' v2 [1][2],
updating 'rabbitmqadmin` v1 tests (e.g. in #15331)
feels like busywork and completely unnecessary.

1. https://github.com/rabbitmq/rabbitmqadmin-ng
2. https://www.rabbitmq.com/docs/management-cli
All of our efforts go into 'rabbitmqadmin' v2 [1][2],
updating 'rabbitmqadmin` v1 tests (e.g. in #15331)
feels like busywork and completely unnecessary.

1. https://github.com/rabbitmq/rabbitmqadmin-ng
2. https://www.rabbitmq.com/docs/management-cli

(cherry picked from commit 94702b3)
michaelklishin added a commit that referenced this pull request Jan 22, 2026
All of our efforts go into 'rabbitmqadmin' v2 [1][2],
updating 'rabbitmqadmin` v1 tests (e.g. in #15331)
feels like busywork and completely unnecessary.

1. https://github.com/rabbitmq/rabbitmqadmin-ng
2. https://www.rabbitmq.com/docs/management-cli

(cherry picked from commit 94702b3)
@michaelklishin michaelklishin merged commit 62db18d into v4.2.x Jan 22, 2026
291 checks passed
@michaelklishin michaelklishin deleted the mergify/bp/v4.2.x/pr-15320 branch January 22, 2026 20:09
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.

2 participants