Skip to content

Add set_default_queue_type migration option#86

Draft
lukebakken wants to merge 5 commits into
feature/allow-message-ttl-gh-80from
feature/set-default-queue-type-gh-79
Draft

Add set_default_queue_type migration option#86
lukebakken wants to merge 5 commits into
feature/allow-message-ttl-gh-80from
feature/set-default-queue-type-gh-79

Conversation

@lukebakken

Copy link
Copy Markdown
Contributor

Summary

Adds an opt-in set_default_queue_type option to the start-migration request. When set to "quorum" or "classic", the virtual host's default queue type is set to that value after a successful migration. When unset, the vhost default is left unchanged.

This addresses the redeclaration failure described in #79: after migrating classic queues to quorum, clients that declare queues without an explicit x-queue-type and rely on the vhost default fail to redeclare the migrated queues with a 406. Setting the vhost default to quorum makes the broker inject x-queue-type: quorum into such declarations so they match the migrated queue.

Closes #79.

Decisions vs the issue's open questions

The issue left several choices open. This PR resolves them as follows:

  • String form, not boolean. The option is set_default_queue_type accepting "quorum" or "classic", rather than the boolean set_default_queue_type_quorum. The string form is more flexible and any other value is rejected with a 400.
  • Applied on every successful run. The default is set whenever a migration run completes successfully, not only on the run that fully drains the vhost of eligible classic queues. This keeps batched runs predictable: each successful run leaves the vhost default in the requested state.
  • Overwrites any existing default. Since the caller explicitly asked for a specific type, an existing non-matching default is overwritten rather than rejected.
  • Best-effort, never fails the migration. If setting the vhost default fails for any reason, the failure is logged and the migration is still reported as successful. A migration that moved data must not be reported as failed because of a metadata write.

It only affects newly declared or redeclared queues that omit x-queue-type; it does not change any existing queue.

Not included

The web UI checkbox/selector suggested in the issue is not part of this PR. This change covers the HTTP API, engine, and tests.

Implementation

  • rqm_mgmt parses and strictly validates the option (invalid value returns 400).
  • rqm sets the vhost default via rabbit_vhost:update_metadata/3 after post_migration_stats, using the plugin's existing internal_user acting user, wrapped so no failure can propagate.
  • The check endpoint accepts and validates the option but a check does not modify the vhost.

Testing

  • Erlang unit tests cover option parsing (quorum/classic accepted, absent leaves it unset, invalid rejected). make ct-unit green.
  • A global --set-default-queue-type=quorum|classic argument was added to the integration harness so any test can request it; the end-to-end test verifies the vhost default was set after migration, and the end-to-end Makefile target exercises it with quorum.
  • Ran the end-to-end integration test live against a 3-node 3.13.7 cluster: the vhost default was set to quorum as requested.

Stacked PR

This is stacked on #85 (allow_message_ttl). The base branch is feature/allow-message-ttl-gh-80; please merge #85 first. The diff shown here is only the set_default_queue_type commits.

Add a `set_default_queue_type` field to the `migration_opts` record and
parse it from the start-migration request body. Valid values are
`quorum` and `classic`; any other value is rejected. Absent leaves the
vhost default queue type untouched (the default).

This commit only wires up parsing and validation; nothing applies the
value yet. Setting the vhost default queue type on successful migration
follows in a later commit for gh-79.
When `set_default_queue_type` is given, set the virtual host's default
queue type (to `quorum` or `classic`) after the migration completes
successfully, via `rabbit_vhost:update_metadata`. This is the feature
behind gh-79: clients that omit `x-queue-type` and rely on the vhost
default then resolve to the migrated queue type.

The step is strictly best-effort and never fails the migration, which
has already completed and restored normal operations by this point. Both
an `{error, _}` return and any raised exception (update_metadata throws
if its Mnesia transaction fails) are caught and logged; the migration
result is unaffected.
Cover the new option in unit_SUITE: `quorum` and `classic` parse to the
expected value, an absent option leaves the key unset, and an invalid
value (e.g. `stream`, `bogus`) is rejected.
Add a global `--set-default-queue-type=quorum|classic` argument that any
test can pass. The value rides along on whatever migration the test
triggers via QueueMigrationClient, without changing the startMigration
call signatures.

When the option is set, the end-to-end test verifies the vhost default
queue type was set to the requested value after a successful migration,
reading it from the management API (which reports "undefined" when
unset). The end-to-end Makefile target exercises this with `quorum`.
Describe the new option on the start endpoint (accepted values, that it
overwrites the existing default, affects only newly declared or
redeclared queues, and is best-effort so it never fails the migration),
add a curl example, and note that the check endpoint accepts and
validates it but a check does not modify the vhost.
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.

1 participant