Skip to content

Modify default queue type injection logic #13837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 5, 2025
Merged

Conversation

mkuratczyk
Copy link
Contributor

There were a few issues:

  1. BUG: rabbitmqctl export definitions - would export the default_queue_type within vhost's metadata if set explicitly (correct) but also outside of the metadata block even if not set explicitly for the vhost (not correct)
  2. BUG/consistency issue: HTTP API / rabbitmqadmin would always export the default queue type in both places
  • outside of the metadata block is just redundant
  • inside the metadata block is inconsistent with rabbitmqctl export_definitions (the difference stems from the fact that CTL only exports existing vhosts' metadata, while HTTP API injects the configuration-level DQT into each vhost's metadata upon export)
  1. The aforementioned inject-upon-export logic is prone to confusion: I can have a system with no DQT configuration and export definitions from it, then restart with a DQT on the node configuration level and export again. The exports will be different because the configuration-level default changed and the current default is injected into the export.

This PR changes the DQT logic: no DQT is injected upon export because it's injected/inherited from the node's configuration into vhost's metadata when a vhost is declared. Therefore each vhost has its own DQT explicitly defined and it's always present in any export (both CTL and HTTP API).

The downsides of this approach is that export/import between systems with a different configuration-level DQT will now require adjusting the DQT in the JSON file

However the logic is should be easier now and more consistent with how queue-level DQT works: when a queue is declared without a type, the default queue type is injected. Going forward, DQT changes don't affect the queue. Similarly, now if a vhost with no DQT is declared, configuration-level DQT is injected and configuration changes don't affect existing vhosts.

mkuratczyk added 5 commits May 1, 2025 17:28
The correct place for the `default_queue_type` property
is inside the `metadata` block. However, right now we'd
always export the value outside of `metadata` AND only
export it inside `metadata`, if it was not `undefined`.

This value outside of `metadata` was just misleading:
if a user exported the definitins from a fresh node,
changed `classic` to `quorum` and imported such modified
values, the DQT would still be `classic`, because RMQ looks
for the value inside `metadata`. Just to make it more confusing,
if the DQT was changed successfully one way or another, the
value outside of `metadata` would reflect that
(it always shows the correct value, but is ignored on import).
Rather than injecting node-level DQT when exporting definitions,
inject it into vhost's metadata when a vhost is created.
Vhosts that currently don't have their own default queue type, now
inherit it from the node configuration and store it in their metadata
going forward.
@lukebakken lukebakken self-requested a review May 1, 2025 16:39
@lukebakken lukebakken self-assigned this May 1, 2025
@michaelklishin
Copy link
Collaborator

@lukebakken @mkuratczyk and I have discussed this in detail, there is also at least one related change in rabbitmqadmin that we'd like to do.

With this change, the injection of the DQT moves from definition export time to virtual host creation time, which is easier to reason about and avoids inconsistent or surprising behavior in a number of scenarios.

@michaelklishin
Copy link
Collaborator

@mkuratczyk FTR, the rabbitmqadmin part is done in rabbitmq/rabbitmqadmin-ng@3098dc2.

Copy link
Contributor

@dcorbacho dcorbacho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. It seems the cleanest and simplest way to present the info.

@mkuratczyk mkuratczyk marked this pull request as ready for review May 5, 2025 10:58
@mkuratczyk mkuratczyk changed the title WIP: Modify default queue type logic Modify default queue type logic May 5, 2025
@michaelklishin michaelklishin changed the title Modify default queue type logic Modify default queue type injection logic May 5, 2025
@michaelklishin michaelklishin added this to the 4.2.0 milestone May 5, 2025
@michaelklishin michaelklishin merged commit 53f511f into main May 5, 2025
273 checks passed
@michaelklishin michaelklishin deleted the dqt-export-fix branch May 5, 2025 17:20
michaelklishin added a commit that referenced this pull request May 5, 2025
Modify default queue type injection logic (backport #13837)
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