Commit Graph

3397 Commits

Author SHA1 Message Date
Michael Klishin e936638569
Merge pull request #13370 from rabbitmq/gazelle-main
bazel run gazelle
2025-02-19 15:41:01 -05:00
Arnaud Cogoluègnes e818136b09
Merge pull request #13360 from rabbitmq/remove-set-stream-retention-policy-command
Remove set_stream_retention_policy command
2025-02-19 09:38:14 +00:00
GitHub 9a9c543a85 bazel run gazelle 2025-02-19 04:02:33 +00:00
Michael Klishin 819b80bfc9
Merge pull request #13365 from rabbitmq/cow-uri
Delete rabbit_uri
2025-02-18 11:36:06 -05:00
David Ansari 2350299fde Delete rabbit_uri
Since https://github.com/rabbitmq/rabbitmq-server/pull/13242 updated
Cowlib to v2.14.0, this commit deletes rabbit_uri as written in the
comments of rabbit_uri.erl:
```
This file is a partial copy of
https://github.com/ninenines/cowlib/blob/optimise-urldecode/src/cow_uri.erl
We use this copy because:
1. uri_string:unquote/1 is lax: It doesn't validate that characters that are
   required to be percent encoded are indeed percent encoded. In RabbitMQ,
   we want to enforce that proper percent encoding is done by AMQP clients.
2. uri_string:unquote/1 and cow_uri:urldecode/1 in cowlib v2.13.0 are both
   slow because they allocate a new binary for the common case where no
   character was percent encoded.
When a new cowlib version is released, we should make app rabbit depend on
app cowlib calling cow_uri:urldecode/1 and delete this file (rabbit_uri.erl).
```
2025-02-18 15:46:16 +01:00
David Ansari 7e7173000f Recover "received timestamp" when reading from stream
When reading from a stream recover the message container annotation `rts` (received timestamp).
2025-02-18 15:11:15 +01:00
Arnaud Cogoluègnes 7ea2ff2651
Remove set_stream_retention_policy command
It is not working as expected. Policies are the way to change data retention for stream.
2025-02-18 11:06:04 +01:00
Péter Gömöri fb21a19b72 Optimise msg_store recovery in case of large message file
Since 4.0.0 (commit d45fbc3d) the shared message store writes large
messages into their own rdq files. This information can be utilised
when scanning rdq files during recovery to avoid reading in the whole
message body into memory unnecessarily.

This commit addresses the same issue that was addressed in 3.13.x by
commit baeefbec (ie. appending a large binary together from 4MB chunks
leaves a lot of garbage and memory fragmentation behind) but even more
efficiently.

Large messages which were written before 4.0.0, which don't fully fill
the rdq file, are still handled as before.
2025-02-14 17:16:43 +01:00
David Ansari 0ee5e74a73 Fix flake in test consume_from_replica
```
make -C deps/rabbit ct-rabbit_stream_queue t=cluster_size_3_parallel_1 RABBITMQ_METADATA_STORE=mnesia
```

flaked prior to this commit locally on Ubuntu with the following error after 11 runs:
```
rabbit_stream_queue_SUITE > cluster_size_3_parallel_1 > consume_from_replica
{error,
    {{shutdown,
         {server_initiated_close,406,
             <<"PRECONDITION_FAILED - stream queue 'consume_from_replica' in vhost '/' does not have a running replica on the local node">>}},
     {gen_server,call,
         [<0.8365.0>,
          {subscribe,
              {'basic.consume',0,<<"consume_from_replica">>,
                  <<"ctag">>,false,false,false,false,
                  [{<<"x-stream-offset">>,long,0}]},
              <0.8151.0>},
          infinity]}}}
```
2025-02-14 13:40:25 +01:00
Michael Klishin a24aef632e
Merge pull request #13307 from rabbitmq/recover-exch-rk-from-amqp
Mc: introduce new function in mc_amqp to init mc from stream data
2025-02-13 13:14:29 -05:00
Jean-Sébastien Pédron d14aa07475
Merge pull request #13329 from rabbitmq/increase-parallel-ct-sets-dedicated-tcp-range
Increase the TCP ports range used by `parallel-ct-set-*`
2025-02-13 17:49:38 +01:00
Jean-Sébastien Pédron e76c227131
Increase the TCP ports range used by parallel-ct-set-*
[Why]
We see nodes trying to use busy ports in CI from time to time.
2025-02-13 15:37:39 +01:00
Arnaud Cogoluègnes f3d8eaadb0
Merge pull request #13324 from rabbitmq/jms-tests-infra
Use JUnit extension to configure JMS tests
2025-02-13 13:52:58 +00:00
Jean-Sébastien Pédron 3887256142
Merge pull request #13323 from rabbitmq/adapt-clustering_management_SUITE-to-khepri-0.17.0
clustering_management_SUITE: Use old node as seed node
2025-02-13 13:05:01 +01:00
David Ansari 6366eafa3b Simplify 2025-02-13 12:46:09 +01:00
Karl Nilsson 32615bf5f0 Mc: introduce new function in mc_amqp to init mc from stream.
Initialising a message container from data stored in a
stream is a special case where we need to recover exchange
and routing key information from the following message annatations:

* x-exchange
* x-routing-keys
* x-cc

We do not want to do this when initialising a message container
from AMQP data just received from a publisher.

This commit introduces a new function `mc_amqp:init_from_stream/2`
that is to be used when needing a message container from a stream
message.
2025-02-13 10:52:12 +00:00
Arnaud Cogoluègnes 7d8f83c919
Control queue type with annotation in JMS tests 2025-02-13 10:44:09 +01:00
Jean-Sébastien Pédron f088c4f544
clustering_management_SUITE: Skip `start_with_invalid_schema_in_path` with Khepri
[Why]
This test plays with the Mnesia database explicitly.
2025-02-13 10:39:54 +01:00
Arnaud Cogoluègnes d574e66dcc
Use AssertJ instead of JUnit assertions in JMS tests 2025-02-13 10:32:38 +01:00
Jean-Sébastien Pédron e76233a222
clustering_management_SUITE: Use old node as seed node
[Why]
During mixed-version testing, the old node might not be able to join or
rejoin a cluster if the other nodes run a newer Khepri machine version.

[How]
The old node is used as the cluster seed node and is never touched
otherwise. Other nodes are restarted or join the cluster later.
2025-02-13 10:25:07 +01:00
Arnaud Cogoluègnes cb59ad877c
Set up JMS destination in JUnit extension 2025-02-13 09:56:20 +01:00
Arnaud Cogoluègnes 9592c2cbec
Merge branch 'main' into dependabot/maven/deps/rabbit/test/amqp_jms_SUITE_data/main/org.apache.maven.plugins-maven-compiler-plugin-3.13.0 2025-02-13 08:44:49 +00:00
Arnaud Cogoluègnes 5fe2693d4a
Merge pull request #13290 from rabbitmq/dependabot/maven/deps/rabbit/test/amqp_jms_SUITE_data/main/com.diffplug.spotless-spotless-maven-plugin-2.44.2
build(deps): bump com.diffplug.spotless:spotless-maven-plugin from 2.43.0 to 2.44.2 in /deps/rabbit/test/amqp_jms_SUITE_data
2025-02-13 08:37:43 +00:00
Arnaud Cogoluègnes d372c03771
Merge pull request #13286 from rabbitmq/dependabot/maven/deps/rabbit/test/amqp_jms_SUITE_data/main/org.junit.jupiter-junit-jupiter-engine-5.11.4
build(deps-dev): bump org.junit.jupiter:junit-jupiter-engine from 5.10.2 to 5.11.4 in /deps/rabbit/test/amqp_jms_SUITE_data
2025-02-13 08:37:13 +00:00
dependabot[bot] e20fd4ab16
build(deps): bump com.diffplug.spotless:spotless-maven-plugin
Bumps [com.diffplug.spotless:spotless-maven-plugin](https://github.com/diffplug/spotless) from 2.43.0 to 2.44.2.
- [Release notes](https://github.com/diffplug/spotless/releases)
- [Changelog](https://github.com/diffplug/spotless/blob/main/CHANGES.md)
- [Commits](https://github.com/diffplug/spotless/compare/lib/2.43.0...maven/2.44.2)

---
updated-dependencies:
- dependency-name: com.diffplug.spotless:spotless-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-13 08:34:30 +00:00
dependabot[bot] 35712d0afc
build(deps-dev): bump org.junit.jupiter:junit-jupiter-engine
Bumps [org.junit.jupiter:junit-jupiter-engine](https://github.com/junit-team/junit5) from 5.10.2 to 5.11.4.
- [Release notes](https://github.com/junit-team/junit5/releases)
- [Commits](https://github.com/junit-team/junit5/compare/r5.10.2...r5.11.4)

---
updated-dependencies:
- dependency-name: org.junit.jupiter:junit-jupiter-engine
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-13 08:34:27 +00:00
dependabot[bot] 9f74ecefae
build(deps): bump org.apache.maven.plugins:maven-compiler-plugin
Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.12.1 to 3.13.0.
- [Release notes](https://github.com/apache/maven-compiler-plugin/releases)
- [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.12.1...maven-compiler-plugin-3.13.0)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-compiler-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-13 08:34:24 +00:00
dependabot[bot] 0b480399a5
build(deps): bump org.apache.maven.plugins:maven-surefire-plugin
Bumps [org.apache.maven.plugins:maven-surefire-plugin](https://github.com/apache/maven-surefire) from 3.2.5 to 3.5.2.
- [Release notes](https://github.com/apache/maven-surefire/releases)
- [Commits](https://github.com/apache/maven-surefire/compare/surefire-3.2.5...surefire-3.5.2)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-surefire-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-02-13 08:34:22 +00:00
David Ansari c5867a7bd3 Add 4.1.0 release notes 2025-02-12 17:17:28 +01:00
Arnaud Cogoluègnes 4ec2b755ee Use ProtonJ2 in JMS-to-AMQP interop test 2025-02-12 17:17:28 +01:00
Arnaud Cogoluègnes fd350386a9 Add helpers for JMS tests 2025-02-12 17:17:28 +01:00
David Ansari 9062476a18 Support dynamic creation of queues
## What?
Support the `dynamic` field of sources and targets.

 ## Why?
1. This allows AMQP clients to dynamically create exclusive queues, which
   can be useful for RPC workloads.
2. Support creation of JMS temporary queues over AMQP using the Qpid JMS
   client. Exclusive queues map very nicely to JMS temporary queues
   because:

> Although sessions are used to create temporary destinations, this is only
for convenience. Their scope is actually the entire connection. Their
lifetime is that of their connection and any of the connection’s sessions
are allowed to create a consumer for them.

https://jakarta.ee/specifications/messaging/3.1/jakarta-messaging-spec-3.1#creating-temporary-destinations

 ## How?
If the terminus contains the capability `temporary-queue` as defined in
[amqp-bindmap-jms-v1.0-wd10](https://groups.oasis-open.org/higherlogic/ws/public/document?document_id=67638)
[5.2] and as sent by Qpid JMS client,
RabbitMQ will create an exclusive queue.
(This allows a future commit to take other actions if capability
`temporary-topic` will be used, such as the additional creation of bindings.)

No matter what the desired node properties are, RabbitMQ will set the
lifetime policy delete-on-close deleting the exclusive queue when the
link which caused its creation ceases to exist. This means the exclusive
queue will be deleted if either:
* the link gets detached, or
* the session ends, or
* the connection closes

Although the AMQP JMS Mapping and Qpid JMS create only a **sending** link
with `dynamic=true`, this commit also supports **receiving** links with
`dynamic=true` for non-JMS AMQP clients.

RabbitMQ is free to choose the generated queue name. As suggested by the
AMQP spec, the generated queue name will contain the container-id and link
name unless they are very long.

Co-authored-by: Arnaud Cogoluègnes <acogoluegnes@gmail.com>
2025-02-12 17:17:28 +01:00
David Ansari 06ec8f0342 Orderly shutdown of sessions
Make AMQP 1.0 connection shut down its sessions before sending the
close frame to the client similar to how the AMQP 0.9.1 connection
shuts down its channels before closing the connection.

This commit avoids concurrent deletion of exclusive queues by the session process
and the classic queue process.
This commit should also fix https://github.com/rabbitmq/rabbitmq-server/issues/2596
2025-02-12 17:17:28 +01:00
Jean-Sébastien Pédron 5cbda4c838
rabbit_stream_queue_SUITE: Swap uses of node 2 and 3 in `format`
[Why]
We hit some transient errors with the previous order when doing
mixed-version testing. Swapping the nodes seems to fix the problem.
2025-02-11 15:50:07 +01:00
Jean-Sébastien Pédron 30fb8a719f
feature_flags_SUITE: Change clustering seed node in few tests
[Why]
Some testcases used to use node 1 as the clustering seed node. With
mixed-version testing, it could cause issues because node 1 would start
with a new version of Ra compared to node 2 and node 2 could fail to
join.

[How]
By using node 2 as the seed node, node 1 running a newer version of Ra
should be able to join because it supports talking to an older version.
2025-02-11 12:10:33 +01:00
Jean-Sébastien Pédron c78aec7d48
rabbit_db: `force_reset` command is unsupported with Khepri
[Why]
The `force_reset` command simply removes local files on disk for the
local node.

In the case of Ra, this can't work because the rest of the cluster does
not know about the forced-reset node. Therefore the leader will continue
to send `append_entry` commands to the reset node.

If that forced-reset node restarts and receives these messages, it will
either join the cluster again (because it's on an older Raft term) or it
will hit an assertion and exit (because it's on the same Raft term).

[How]
Given we can't really support this scenario and it has little value, the
command will now return an error if someone attemps a `force_reset` with
a node running Khepri.

This also deprecates the command: once Mnesia support is removed, the
command will be removed at the same time. This is noted in the
rabbitmqctl.8 manpage.
2025-02-10 15:09:36 +01:00
Frederik Bosch b821e52329 disable consul health check helper when registration is disabled 2025-02-06 14:18:18 +01:00
GitHub c6cdc40f1a bazel run gazelle 2025-02-05 04:02:24 +00:00
Michal Kuratczyk a9d5b6001a
k8s peer discovery v2 (#13050)
* Redesigned k8s peer discovery

Rather than querying the Kubernetes API, just check the local node name
and try to connect to the pod with `-0` suffix (or configured
`ordinal_start` value). Only the pod with the lowest ordinal can form
a new cluster - all other pods will wait forever.

This should prevent any race conditions and incorrectly formed clusters.
2025-02-04 17:07:27 +01:00
David Ansari 7bc3ab8cd4 Add tests for different JMS message types
This commit contains the following changes:
1. Simplify .NET suite
2. Simplify Java package naming
3. Extract JMS tests into separate suite. This way, it's easier to run,
debug, and add new tests compared to the previous suite which mixed
.NET tests with JMS tests.
4. Add tests for different JMS message types
2025-02-04 14:46:49 +01:00
Michael Klishin b4f5d3d51a
Core config_schema_SUITE: cosmetics 2025-02-03 19:14:25 -05:00
Michael Klishin 269685dd6e
Make it possible to opt out of peer discovery registration
for the backends that support it in the first place.

When forming a cluster, registration of the node
joining the cluster might be left to (container)
orchestration tools like Nomad or Kubernetes.

This PR add a new configuration option,
'cluster_formation.registration.enable',
which defaults to true.
When set to false node registration will be skipped.

There is at least one important advantage using a
tool such as Nomad (plus Consul) over the application
(RabbitMQ) doing the registration.

When the application is not stopped gracefully for
any reason, e.g. its OOM killed,
it cannot deregister the service/node.

This leaves behind an unlinked service entry in the registry.
This problem is fundamentally avoided by allowing
Nomad (or similar tools) to register the
node'service.

See #11233  #11045 for prior discussions.

Co-authored-by: Frederik Bosch <f.bosch@genkgo.nl>
2025-02-03 13:58:17 -05:00
David Ansari 0b1cfc6f04
Impose limit on AMQP filter complexity
As described in section 7.1 of filtex-v1.0-wd09:
> Impose a limit on the complexity of each filter expression.

Here, we hard code the maximum properties within a filter expression to 16.
There should never be a use case requiring to filter on more than 16
different properties.
2025-02-03 11:57:43 -05:00
David Ansari 4bdddc7a98
Bump Qpid JMS AMQP 1.0 client 2025-02-03 11:57:43 -05:00
Michael Klishin df424e5edf
Bump Khepri cluster formation timeout
to match that used with Mnesia.

In the case of Mnesia, there are 10 retries
with a 30 second delay each.

For Khepri, a single timeout is used, so it
must be ten times as long.
2025-02-03 11:57:42 -05:00
Frederik Bosch 481ffb2d6c add option to disable registration of node during cluster formation 2025-02-01 14:09:03 +01:00
Frederik Bosch 8355bc691e add option to disable registration of node during cluster formation 2025-02-01 13:36:22 +01:00
Michal Kuratczyk 198d8f93d3
Make sure there are no duplicates on the nodes list
This is probably more of a CI bug than anything else - in CI we use
a lower tick value, which increases the odds of the periodic
repair triggering very early.

Failure:
https://github.com/rabbitmq/rabbitmq-server/actions/runs/13013004042/job/36295172214?pr=13050
2025-01-28 17:10:13 +01:00
Karl Nilsson 7862c2f501
Merge pull request #12713 from rabbitmq/ra-2.16.0
Ra v2.16.0
2025-01-28 16:00:08 +01:00
GitHub a013bb1d1c bazel run gazelle 2025-01-28 04:02:47 +00:00
David Ansari 579c58603e Support AMQP over WebSocket (OSS part) 2025-01-27 17:50:47 +01:00
Karl Nilsson e58b8ebc1d QQ: refactor add_member method to pass dialyzer
And be less confusing around the arguments that add_member/4 actually
takes.
2025-01-27 13:50:38 +00:00
Karl Nilsson 113b16bbc4 Use initial_machine_version config to avoid initalising
from rabbit_fifo version 0.

The same was also implemented for the stream coordinator.

QQ: avoid dead lock in queue federation.

When processing the queue federation startup even the process
may call back into the ra process causing a deadlock. in this
case we spawn a temporary process to avoid this.
2025-01-27 13:50:38 +00:00
Karl Nilsson f2b1f37331 QQ: Use new log_ext effect
This offloads the work of reading messages from on-disk segments
to the interacting process rather than doing this blocking, performance
affecting work in the ra server process.

QQ: ensure opened segments are closed after some time of inactivity

Processes that havea received messages that had to be read from disks
may keep a segment open indefinitely. This introduces a timer which
after some time of inactivity will close all opened segments to ensure
file descriptors are not kept open indefinitely.
2025-01-27 13:50:38 +00:00
Jean-Sébastien Pédron f549425615
rabbitmq_ct_broker_helpers: Use node 2 as the cluster seed node
[Why]
When running mixed-version tests, nodes 1/3/5/... are using the primary
umbrella, so usually the newest version. Nodes 2/4/6/... are using the
secondary umbrella, thus the old version.

When clustering, we used to use node 1 (running a new version) as the
seed node, meaning other nodes would join it.

This complicates things with feature flags because we have to make sure
that we start node 1 with new stable feature flags disabled to allow old
nodes to join.

This is also a problem with Khepri machine versions because the cluster
would start with the latest version, which old nodes might not have.

[How]
This patch changes the logic to use a node running the secondary
umbrella as the seed node instead. If there is no node running it, we
pick the first node as before.

V2: Revert part of "rabbitmq_ct_helpers: Fix how we set
    `$RABBITMQ_FEATURE_FLAGS` in tests" (commit
    57ed962ef6). These changes are no
    longer needed with the new logic.

V3: The check that verifies that the correct metadata store is used has
    a special case for nodes that use the secondary umbrella: if Khepri
    is supposed to be used but it's not, the feature flag is enabled.
    The reason is that the `v4.0.x` branch doesn't know about the `rel`
    configuration of `forced_feature_flags_on_init`. The nodes will
    have ignored thies parameter and booted with the stable feature
    flags only.

    Many testsuites are adapted to the new clustering order. If they
    manage which node joins which node, either the order is changed in
    the testcases, or nodes are started with only required feature
    flags. For testsuites that rely on peer discovery where the order is
    unknown, nodes are started with only required feature flags.
2025-01-27 12:08:12 +01:00
Michael Klishin 28602bea37
scripts/rabbitmqctl: allow standard input reads for 'import_definitions'
It was not listed in 7da7d4e1e, even though the command
accepts definitions via standard input.

References #10268.
Closes #13157.
2025-01-26 18:36:08 -05:00
Michael Klishin a3decfa69e
Merge pull request #13115 from rabbitmq/issue-13040
Support exchange federation with MQTT 5.0 subscribers
2025-01-25 16:25:26 -05:00
Simon c9f060d921
Merge branch 'main' into su_aws/limit_logging_error_with_tests 2025-01-24 15:55:37 -08:00
Simon Unge 3702b00471 Log incorrectly claims the limit is per node, but the component count is over all vhost in the cluster 2025-01-24 23:54:11 +00:00
Michael Klishin de088f8947
Revert "Log incorrectly claims the limit is per node," 2025-01-24 16:42:52 -05:00
Michael Klishin 79dd5038f7
Merge pull request #13149 from rabbitmq/su_aws/limit_logging_error
Log incorrectly claims the limit is per node,
2025-01-24 14:10:00 -05:00
Simon Unge c93cacf477 Log incorrectly claims the limit is per node, but the component count is over all vhost in the cluster 2025-01-24 18:22:57 +00:00
Arnaud Cogoluègnes a67634fcf1
Merge pull request #13146 from rabbitmq/queue-purge-return-not-found-if-queue-does-not-exist
Return 404 in AMQP management queue purge for non-existing queue
2025-01-24 15:59:17 +00:00
Jean-Sébastien Pédron aeca23c69d
amqp_client_SUITE: Fix several test flakes
[How]
1. Use feature flags correctly: the code shouldn't test if a feature
   flag is enabled, assuming something else enabled it. It should enable
   it and react to an error.
2. Use `close_connection_sync/1` instead of the asynchronous
   `amqp10_client:close_connection/1` to make sure they are really
   closed. The wait in `end_per_testcase/2` was not enough apparently.
3. For the two testcases that flake the most for me, enclose the code in
   a try/after and make sure to close the connection at the end,
   regardless of the result. This should be done for all testcases
   because the testgroup use a single set of RabbitMQ nodes for all
   testcases, therefore testcases are supposed to clean up after them...
2025-01-24 15:38:11 +01:00
Arnaud Cogoluègnes 7bfe2fd66f
Return 404 in AMQP management queue purge for non-existing queue 2025-01-24 14:57:44 +01:00
David Ansari 1267d5986d Simplify Direct Reply-To
This commit is no change in functionality and mostly deletes dead code.

1. Code targeting Erlang 22 and below is deleted since the mininmum
   required Erlang version is higher nowadays.
   "In OTP 23 distribution flag DFLAG_BIG_CREATION became mandatory. All
   pids are now encoded using NEW_PID_EXT, even external pids received
   as PID_EXT from older nodes."
   https://www.erlang.org/doc/apps/erts/erl_ext_dist.html#new_pid_ext
2. All v1 encoding and decoding of the Pid is deleted since the lower
   version RabbitMQ node supports the v2 encoding nowadays.
2025-01-23 19:16:30 +01:00
Karl Nilsson 2f89bd9122
Merge pull request #13095 from rabbitmq/qq-resend-pending-commands-on-applied
QQ: resend pending commands when new leader detected on applied notif…
2025-01-22 20:43:31 +01:00
Karl Nilsson d31b9aa8a3 QQ: resend pending commands when new leader detected on applied notification.
When a leader changes all enqueuer and consumer processes are notified
from the `state_enter(leader,` callback. However a new leader may not
yet have applied all commands that the old leader had. If any of those
commands is a checkout or a register_enqueuer command these processes
will not be notified of the new leader and thus may never resend their
pending commands.

The new leader will however send an applied notification when it does
apply these entries and these are always sent from the leader process
so can also be used to trigger pending resends. This commit implements
that.
2025-01-22 13:38:21 +00:00
David Ansari 3a65695d0a Support exchange federation with MQTT 5.0 subscribers
## What?
This commit fixes #13040.

Prior to this commit, exchange federation crashed if the MQTT topic exchange
(`amq.topic` by default) got federated and MQTT 5.0 clients subscribed on the
downstream. That's because the federation plugin sends bindings from downstream
to upstream via AMQP 0.9.1. However, binding arguments containing Erlang record
`mqtt_subscription_opts` (henceforth binding args v1) cannot be encoded in AMQP 0.9.1.

 ## Why?
Federating the MQTT topic exchange could be useful for warm standby use cases.

 ## How?
This commit makes binding arguments a valid AMQP 0.9.1 table (henceforth
binding args v2).

Binding args v2 can only be used if all nodes support it. Hence binding
args v2 comes with feature flag `rabbitmq_4.1.0`. Note that the AMQP
over WebSocket
[PR](https://github.com/rabbitmq/rabbitmq-server/pull/13071) already
introduces this same feature flag. Although the feature flag subsystem
supports plugins to define their own feature flags, and the MQTT plugin
defined its own feature flags in the past, reusing feature flag
`rabbitmq_4.1.0` is simpler.

This commit also avoids database migrations for both Mnesia and Khepri
if feature flag `rabbitmq_4.1.0` gets enabled. Instead, it's simpler to
migrate binding args v1 to binding args v2 at MQTT connection establishment
time if the feature flag is enabled. (If the feature flag is disabled at
connection etablishment time, but gets enabled during the connection
lifetime, the connection keeps using bindings args v1.)

This commit adds two new suites:
1. `federation_SUITE` which tests that federating the MQTT topic
   exchange works, and
2. `feature_flag_SUITE` which tests the binding args migration from v1 to v2.
2025-01-22 11:04:36 +01:00
GitHub a3d0a5af4f bazel run gazelle 2025-01-22 04:02:32 +00:00
Arnaud Cogoluègnes 31a4d611f1
Emit events on stream consume and cancel 2025-01-20 17:24:55 +01:00
Arnaud Cogoluègnes 1886caec0a
Merge pull request #13092 from rabbitmq/stream-consumer-cancel-event
Emit cancellation event only when stream consumer is cancelled
2025-01-17 14:13:08 +00:00
Arnaud Cogoluègnes 69d0382dd2
Emit cancellation event only when stream consumer is cancelled
Not when the channel or the connection is closed.

References #13085, #9356
2025-01-17 14:42:40 +01:00
Michal Kuratczyk 3ff90deb7c
Merge pull request #13069 from rabbitmq/update-startup-checks
Remove deprecated/unused/old startup checks
2025-01-17 14:28:50 +01:00
Michal Kuratczyk 14171fb035
Remove msg_store_io_batch_size and msg_store_credit_disc_bound checks
msg_store_io_batch_size is no longer used

msg_store_credit_disc_bound appears to be used in the code, but I don't
see any impact of that value on the performance. It should be properly
investigated and either removed completely or fixed, because there's
hardly any point in warning about the values configured
(plus, this settings is hopefully almost never used anyway)
2025-01-17 13:38:43 +01:00
Michal Kuratczyk 954b861db7
Don't warn about dirty I/O scheduler count 2025-01-16 17:42:13 +01:00
Péter Gömöri efd4e45ed8 Fix return value of `rabbit_priority_queue:delete_crashed/1`
According to the `rabbit_backing_queue` behavious it must always
return `ok`, but it used to return a list of results one for each
priority. That caused the below crash further up the call chain.

```
> rabbit_classic_queue:delete_crashed(Q)
** exception error: no case clause matching [ok,ok,ok,ok,ok,ok,ok,ok,ok,ok,ok]
     in function  rabbit_classic_queue:delete_crashed/2 (rabbit_classic_queue.erl, line 516)
```

Other backing_queue implementations (`rabbit_variable_queue`) just
exit with a badmatch upon error.

This (very minor) issue is present since 3.13.0 when
`rabbit_classic_queue:delete_crashed_in_backing_queue/1` was
instroduced with Khepri in commit 5f0981c5. Before that the result of
`BQ:delete_crashed/1` was simply ignored.
2025-01-16 17:34:19 +01:00
Arnaud Cogoluègnes 114a5c220f
Delete stream consumer metrics when AMQP 091 connection closes (#13085)
To avoid rogue consumer records.
2025-01-16 15:40:06 +01:00
Karl Nilsson e7c624dd46 QQ: improve fifo client log message on leader change
to capture the number of pending commands that will be resent
2025-01-16 09:36:23 +00:00
David Ansari 290889b936 Include sessions in format_status/1
Include monitored session pids in format_status/1 of rabbit_amqp_writer.
They could be useful when debugging.
The maximum number of sessions per connection is limited, hence the
output won't be too large.
2025-01-16 10:06:24 +01:00
Jean-Sébastien Pédron 57ed962ef6
rabbitmq_ct_helpers: Fix how we set `$RABBITMQ_FEATURE_FLAGS` in tests
[Why]
In order to make `khepri_db` the default in the future, the handling of
`$RABBITMQ_FEATURE_FLAGS` had to be adapted to be able to *disable*
Khepri instead.

Unfortunately I broke the behavior with stable feature flags that are
only available in the primary umbrella. In this case, they were
automatically enabled and thus, clustering with an old umbrella that did
not have these feature flags failed with `incompatible_feature_flags`.

[How]
The solution is to always use an absolute list of feature flags, not the
new relative list.

V2: Allow a testsuite to skip the configuration of the metadata store.
    This is needed for the feature_flags_SUITE testsuite because it
    tests the default behavior and the configuration of the metadata
    store changes that behavior.

    While here, fix a ct log message where variables were swapped
    compared to the format strieg expectation.

V3: Enable `rabbitmq_4.0.0` feature flag in rabbit_mgmt_http_SUITE. This
    testsuite apparently requires it and if it's not enabled, it fails.
2025-01-15 20:43:41 +01:00
Michal Kuratczyk a4634d3f70
Allow InitialCredit/MoreCreditAfter of zero (#13067)
https://github.com/rabbitmq/rabbitmq-server/pull/13046
introduced additional checks which prevent setting
`{credit_flow_default_credit,{0,0}}`.

Setting credits to zero allows disabling the credit flow mechanism
(we use it in our benchmarks and mention for example in
https://www.rabbitmq.com/blog/2023/03/21/native-mqtt)
2025-01-14 16:12:05 +01:00
Michal Kuratczyk 1077a55194
Stream queue: consumers are active by default
Without this change, consumers using protocols other than the stream
protocol would display as inactive in the Management UI/API and CLI
commands, even though they were receiving messages.
2025-01-13 15:51:39 +01:00
Michael Klishin 208d3d6b59
Follow-up to #13046 #13055: accept MoreCreditAfter that's equal to InitialCredit 2025-01-12 16:48:53 -05:00
Michael Klishin 3dd3433722
Finish off #13046 2025-01-11 19:15:00 -05:00
Michael Klishin e5fe7247dc
rabbitmq.conf.example: a typo #8076 2025-01-11 17:36:51 -05:00
Michael Klishin 82c93ceb23
rabbitmq.conf.example: document quorum_queue.property_equivalence.relaxed_checks_on_redeclaration #8076 2025-01-11 17:36:50 -05:00
Michael Klishin 4603d3597e
rabbitmq.conf.example: suggest Discussions and Discord for questions 2025-01-11 17:36:50 -05:00
jimmy 0135f62528 Fix typo 2025-01-11 14:15:35 +08:00
jimmy 2394d427e3 Fix typo 2025-01-11 13:19:31 +08:00
jimmy e6954c8720 Change to throw an error when credit_flow_default_credit invalid 2025-01-11 13:13:12 +08:00
root e589c42476 Change to throw an error when credit_flow_default_credit invalid 2025-01-11 13:10:17 +08:00
JimmyWang6 81648759f8 Fix typo 2025-01-10 15:50:38 +08:00
jimmy wang 5b244e7504 Fix MoreCreditAfter could larger than InitialCredit 2025-01-10 14:42:10 +08:00
Michael Klishin 1d88a9d28f
definition_import_SUITE: a new case
that features a deletion-protected virtual host.
2025-01-03 19:07:57 -05:00
Michael Klishin 315c247231
Make sure protected_from_deletion is included into virtual host definitions exported over the HTTP API 2025-01-03 18:49:11 -05:00
Michael Klishin 3f5b13d47f
Merge branch 'main' into mk-virtual-host-protection-from-accidental-deletion 2025-01-02 17:01:54 -05:00
Michael Klishin f62d46c286
Introduce a way to protect a virtual host from deletion
Accidental "fat finger" virtual deletion accidents
would be easier to avoid if there was a protection mechanism
that would apply equally even to CLI tools and external
applications that do not use confirmations for deletion
operations.

This introduce the following changes:

 * Virtual host metadata now supports a new queue,
   'protected_from_deletion', which, when set,
   will be considered by key virtual host deletion function(s)
 * DELETE /api/vhosts/{name} was adapted to handle
   such blocked deletion attempts to respond with
   a 412 Precondition Failed status
 * 'rabbitmqctl list_vhosts' and 'rabbitmqctl delete_vhost'
   were adapted accordingly
 * DELETE /api/vhosts/{name}/deletion/protection
   is a new endpoint that can be used to remove
   the protective seal (the metadata key)
 * POST /api/vhosts/{name}/deletion/protection
   marks the virtual host as protected

In the case of the HTTP API, all operations on
virtual host metadata require administrative
privileges from the target user.

Other considerations:

 * When a virtual host does not exist, the behavior
  remains the same: the original, protection-unaware
  code path is used to preserve backwards compatibility

References #12772.
2025-01-02 16:50:51 -05:00
Michael Klishin ac7dcc9abe
Merge pull request #13010 from johanrhodin/link-fix-patch-1
Update doc link
2025-01-02 12:19:04 -05:00
Johan Rhodin e35edf789d
Update doc link 2025-01-02 10:53:19 -06:00
Michael Klishin 2aed29709e
mirrored_supervisor_SUITE: don't search logs for exceptions #13008 2025-01-02 11:05:49 -05:00
Michael Klishin 968eefa1bb
Bump (c) line year
There are no functional changes to this massive diff.
2025-01-01 17:54:10 -05:00
David Ansari 42ede4a258 Speed up tests
Multiple test cases were recently slowed down by up to 30 seconds.
This commit reverts these changes.
2024-12-30 16:56:18 +00:00
Michal Kuratczyk 68de3fdb77
Fix channel crash when publishing to a new stream (#12969)
The following scenario led to a channel crash:
1. Publish to a non-existing stream: `perf-test -y 0 -p -e amq.default -t direct -k stream`
2. Declare the stream: `rabbitmqadmin declare queue name=stream queue_type=stream`

There is no pid yet, so we got a function_clause with `none`
```
{function_clause,
   [{osiris_writer,write,
        [none,<0.877.0>,<<"<0.877.0>_-65ZKFz18ll5lau0phi7CsQ">>,1,
         [[0,"Sp",[192,6,5,"B@@AC"]],
          [0,"Sr",
           [193,38,4,
            [[[163,10,<<"x-exchange">>],[161,0,<<>>]],
             [[163,13,<<"x-routing-key">>],[161,6,<<"stream">>]]]]],
          [0,"Su",[160,12,[<<0,19,252,1,0,0,98,171,20,16,108,167>>]]]]],
        [{file,"src/osiris_writer.erl"},{line,158}]},
    {rabbit_stream_queue,deliver0,4,
        [{file,"rabbit_stream_queue.erl"},{line,540}]},
    {rabbit_stream_queue,'-deliver/3-fun-0-',4,
        [{file,"rabbit_stream_queue.erl"},{line,526}]},
    {lists,foldl,3,[{file,"lists.erl"},{line,2146}]},
    {rabbit_queue_type,'-deliver0/4-fun-5-',5,
        [{file,"rabbit_queue_type.erl"},{line,707}]},
    {maps,fold_1,4,[{file,"maps.erl"},{line,860}]},
    {rabbit_queue_type,deliver0,4,
        [{file,"rabbit_queue_type.erl"},{line,704}]},
    {rabbit_queue_type,deliver,4,
        [{file,"rabbit_queue_type.erl"},{line,662}]}]}
```

Co-authored-by: Karl Nilsson <kjnilsson@gmail.com>
2024-12-20 08:56:25 +01:00
Jean-Sébastien Pédron ea2c8db2d1
rabbit_feature_flags: Add testcase after issue #12963
[Why]
Up-to RabbitMQ 3.13.x, there was a case where if:
1. you enabled a plugin
2. you enabled its feature flags
3. you disabled the plugin
4. you restarted a node (or upgraded it)

... the node could crash on startup because it had a feature flag marked
as enabled that it didn't know about:

    error:{badmatch,#{feature_flags => ...

        rabbit_ff_controller:-check_one_way_compatibility/2-fun-0-/3, line 514
        lists:all_1/2, line 1520
        rabbit_ff_controller:are_compatible/2, line 496
        rabbit_ff_controller:check_node_compatibility_task1/4, line 437
        rabbit_db_cluster:check_compatibility/1, line 376

This was "fixed" by the new way of keeping the registry in memory
(#10988) because it introduces a slight change of behavior. Indeed, the
old way walked through the `FeatureFlags` map and looked up the state in
the `FeatureStates` map to create the `is_enabled/1` function. The new
way just looks up the state in `FeatureStates`.

[How]
The new testcase succeeds on 4.0.x and `main`, but would fail on 3.13.x
with the aforementionne crash.
2024-12-19 16:33:43 +01:00
Jean-Sébastien Pédron 3325def8eb
rabbit_feature_flags: Take callback definition from correct node
[Why]
The feature flag controller that is responsible for enabling a feature
flag may be on a node that doesn't know this feature flag. This is
supported by there is a bug when it queries the callback definition for
that feature flag: it uses its own registry which does not have anything
about this feature flag.

This leads to a crash because the `run_callback/5` funtion tries to use
the `undefined` atom returned by the registry as a map:

    crasher:
      initial call: rabbit_ff_controller:init/1
      pid: <0.374.0>
      registered_name: rabbit_ff_controller
      exception error: bad map: undefined
        in function  rabbit_ff_controller:run_callback/5
        in call from rabbit_ff_controller:do_enable/3 (rabbit_ff_controller.erl, line 1244)
        in call from rabbit_ff_controller:update_feature_state_and_enable/2 (rabbit_ff_controller.erl, line 1180)
        in call from rabbit_ff_controller:enable_with_registry_locked/2 (rabbit_ff_controller.erl, line 1050)
        in call from rabbit_ff_controller:enable_many_locked/2 (rabbit_ff_controller.erl, line 991)
        in call from rabbit_ff_controller:enable_many/2 (rabbit_ff_controller.erl, line 979)
        in call from rabbit_ff_controller:updating_feature_flag_states/3 (rabbit_ff_controller.erl, line 307)
        in call from gen_statem:loop_state_callback/11 (gen_statem.erl, line 3735)

[How]
The callback definition is now queried from the first node in the list
given as argument. For the common use case where all nodes know about a
feature flag, the first node is the local one, so there should be no
latency caused by the RPC.

See #12963.
2024-12-19 13:45:27 +01:00
Jean-Sébastien Pédron dbec429fba
rabbit_feature_flags: Fix function name in the controller
[Why]
`state_after_virtual_state()` meant nothing.

`state_after_virtual_reset()` was the name I had in mind.
2024-12-19 11:54:25 +01:00
Jean-Sébastien Pédron debe2a118c
rabbitmq_ct_helpers: Change how Mnesia/Khepri is selected
[Why]
Once `khepr_db` is enabled by default, we need another way to disable it
to select Mnesia instead.

[How]
We use the new relative forced feature flags mechanism to indicate if we
want to explicitly enable or disable `khepri_db`. This way, we don't
touch other stable feature flags and only mess with Khepri.

However, this mechanism is not supported by RabbitMQ 4.0.x and older.
They will ignore the setting. Therefore, to make this work in
mixed-version testing, we set the `$RABBITMQ_FEATURE_FLAGS` variable for
the secondary umbrella. This part will go away once we test against
RabbitMQ 4.1.x as the secondary umbrella in the future.

At the end, we compare the effective metadata store to the expected one.
If they don't match, we skip the test.

While here, change `rjms_topic_selector_SUITE` to only choose Khepri
without specifying any feature flags.
2024-12-17 09:56:54 +01:00
Michael Klishin 0db3d7b014
Merge pull request #12950 from rabbitmq/qq-handle-tick
Quorum queues: ignore handle_tick with an old overview format
2024-12-16 11:31:55 -05:00
Michael Klishin 62ce1c954a
Merge pull request #12948 from rabbitmq/fix-flakes
Test fixes for a few more CI flakes
2024-12-16 11:24:10 -05:00
Diana Parra Corbacho a97ec92785 Quorum queues: ignore handle_tick with an old overview format
If handle_tick is called before the machine has finished the upgrade
process, it could receive an old overview format (stats tuple vs map).
Let's ignore it and the next handle tick should be fine.

Unlikely to happen in production, detected on CI with a very low tick timeout
2024-12-16 15:39:39 +01:00
Diana Parra Corbacho fe7a141331 Test: Increase receive timeout in all rabbit test suites 2024-12-16 11:58:05 +01:00
GitHub 0d750769f9 bazel run gazelle 2024-12-14 04:02:32 +00:00
David Ansari b6027ece28 Fix dead lettering crash
Fixes #12933

The assumption that `x-last-death-*` annotations must have been set
whenever the `deaths` annotation is set was wrong.

Reproducation steps, Option 1:
1. In v3.13.7, dead letter a message from Q1 to Q2 (both can be classic queues).
2. Re-publish the message including its x-death header from Q2 back to Q1.
(RabbitMQ 3.13.7 will interpret this x-death header and set the deaths annotation.)
3. Upgrade to v4.0.4
4. Dead letter the message from Q1 to Q2 will cause the following crash:
```
crasher:
  initial call: rabbit_amqqueue_process:init/1
  pid: <0.577.0>
  registered_name: []
  exception exit: {{badkey,<<"x-last-death-exchange">>},
                   [{mc,record_death,4,[{file,"mc.erl"},{line,410}]},
                    {rabbit_dead_letter,publish,5,
                        [{file,"rabbit_dead_letter.erl"},{line,38}]},
                    {rabbit_amqqueue_process,'-dead_letter_msgs/4-fun-0-',
                        7,
                        [{file,"rabbit_amqqueue_process.erl"},{line,1060}]},
                    {rabbit_variable_queue,'-ackfold/4-fun-0-',3,
                        [{file,"rabbit_variable_queue.erl"},{line,655}]},
                    {lists,foldl,3,[{file,"lists.erl"},{line,2146}]},
                    {rabbit_variable_queue,ackfold,4,
                        [{file,"rabbit_variable_queue.erl"},{line,652}]},
                    {rabbit_priority_queue,ackfold,4,
                        [{file,"rabbit_priority_queue.erl"},{line,309}]},
                    {rabbit_amqqueue_process,
                        '-dead_letter_rejected_msgs/3-fun-0-',5,
                        [{file,"rabbit_amqqueue_process.erl"},
                         {line,1038}]}]}
```

Reproduction steps, Option 2:
1. Run a 4.0.4 / 3.13.7 mixed version cluster where both queues Q1 and Q2
   are hosted on the 4.0.4 node.
2. Send a message to Q1 which dead letters to Q2.
3. Re-publish a message with the x-death AMQP 0.9.1 header from Q2 to
   Q1. However, this time make sure to publish to the 3.13.7 node which
   forwards this message to Q1 on the 4.0.4 node.
4. Subsequently dead lettering this message from Q1 to Q2 (happening on
   the 4.0.4 node) will also cause the crash.

The modified test case in this commit was able to repro this crash via
Option 2 in the mixed version cluster tests on the `v4.0.x` branch.
2024-12-13 19:25:43 +01:00
Matteo Cafasso 8d7535e0b1
amqqueue_process: adopt new `is_duplicate` backing queue callback
As the de-duplication plugin is the only adopter of the `is_duplicate`
callback, we now use a simpler signature.

When a message is deemed duplicated, we discard it and re-route it to
dead letter exchange.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
(cherry picked from commit f93baa35cb)
2024-12-11 19:43:45 -05:00
Matteo Cafasso 6a6e760107
backing_queue: simplify `is_duplicate` callback signature
`is_duplicate` callback signature was changed in order to support both
the mirroring queues as well as the de-duplication ones.

As the mirroring queues are now deprecated and removed, we can fall
back to a simpler boolean as return value.

Signed-off-by: Matteo Cafasso <noxdafox@gmail.com>
(cherry picked from commit c927446e17)
2024-12-11 19:43:38 -05:00
David Ansari 9d8ae14e27 Use correct AMQP filter expression string modifier prefix
Section 4.1.1 of AMQP Filter Expressions Working Draft 09
defines `&` (ampersand) instead of `$` (dollar) as the string modifier prefix.
2024-12-11 16:48:56 +01:00
Michael Klishin b84483ab5c
Merge pull request #12907 from rabbitmq/rabbitmq-server-12906
By @gomoripeti: Restore credit_flow between AMQP 0.9.1 channel/MQTT connection -> CQ processes
2024-12-10 10:03:47 -05:00
David Ansari 0d34ef6047 Set a floor of zero for incoming-window
Prior to this commit, when the sending client overshot RabbitMQ's incoming-window
(which is allowed in the event of a cluster wide memory or disk alarm),
and RabbitMQ sent a FLOW frame to the client, RabbitMQ sent a negative
incoming-window field in the FLOW frame causing the following crash in
the writer proc:
```
crasher:
  initial call: rabbit_amqp_writer:init/1
  pid: <0.19353.0>
  registered_name: []
  exception error: bad argument
    in function  iolist_size/1
       called as iolist_size([<<112,0,0,23,120>>,
                              [82,-15],
                              <<"pÿÿÿü">>,<<"pÿÿÿÿ">>,67,
                              <<112,0,0,23,120>>,
                              "Rª",64,64,64,64])
       *** argument 1: not an iodata term
    in call from amqp10_binary_generator:generate1/1 (amqp10_binary_generator.erl, line 141)
    in call from amqp10_binary_generator:generate1/1 (amqp10_binary_generator.erl, line 88)
    in call from amqp10_binary_generator:generate/1 (amqp10_binary_generator.erl, line 79)
    in call from rabbit_amqp_writer:assemble_frame/3 (rabbit_amqp_writer.erl, line 206)
    in call from rabbit_amqp_writer:internal_send_command_async/3 (rabbit_amqp_writer.erl, line 189)
    in call from rabbit_amqp_writer:handle_cast/2 (rabbit_amqp_writer.erl, line 110)
    in call from gen_server:try_handle_cast/3 (gen_server.erl, line 1121)
```

This commit fixes this crash by maintaning a floor of zero for
incoming-window in the FLOW frame.

Fixes #12816
2024-12-10 09:39:21 +01:00
Péter Gömöri 2c1f1a1387
Restore credit_flow between channel/MQTT connection -> CQ processes
The credit_flow between publishing AMQP 0.9.1 channel (or MQTT
connection) and (non-mirrored) classic queue processes was
unintentionally removed in 4.0 together with anything else related to
CQ mirroring.

By default we restore the 3.x behaviour for non-mirored classic
queues. It is possible to disable flow-control (the earlier 4.0.x
behaviour) with the new env `classic_queue_flow_control`. In 3.x this
was possible with the config `mirroring_flow_control`.

(cherry picked from commit d65bd7d07a)
2024-12-09 22:33:47 -05:00
Jean-Sébastien Pédron 56f90a51a9
rabbit_db: Return error from `force_boot_command_test/0` with Khepri 2024-12-02 13:33:08 +01:00
Jean-Sébastien Pédron df9882417c
rabbit_khepri: Report no partitions from `cli_cluster_status/0` 2024-11-29 16:53:55 +01:00
Jean-Sébastien Pédron 4621fe7730
mirrored_supervisor: Catch timeout from Khepri in `hanlde_info/2`
[Why]
The code assumed that the transaction would always succeed. It was kind
of the case with Mnesia because it would throw an exception if it
failed.

Khepri returns an error instead. The code has to handle it. In
particular, we see timeouts in CI and before this patch, they caused a
crash because the list comprehension was asked to work on a tuple.

[How]
We now retry a few times for 10 seconds.
2024-11-29 12:03:59 +01:00
Jean-Sébastien Pédron 913bd9fa42
rabbit_db: Fix `rabbit_db_msup:update_all/2` spec
[Why]
It can return an error.
2024-11-29 12:03:35 +01:00
Jean-Sébastien Pédron ae9fbb7bd5
Pin Horus to 0.3.1 temporarily
[Why]
We pin a version of Horus even if we don't use it directly (it is a
dependency of Khepri). But currently, we can't update Khepri while still
needing the fix in Horus 0.3.1.

Horus 0.3.1 works around a crash in `cover` that mostly affects CI for
now.

This pinning will have to go away with the next update of Khepri.
2024-11-29 09:50:08 +01:00
Jean-Sébastien Pédron 99d8e90df3
rabbit_quorum_queue: Wait for member add in `add_member/4`
[Why]
The `ra:member_add/3` call returns before the change is committed. This
is ok for that addition but any follow-up changes to the cluster might
be rejected with the `cluster_change_not_permitted` error.

[How]
Instead of changing other places to wait or retry their cluster
membership change, this patch waits for the current add to be applied
before proceeding and returning.

This fixes some transient failures in CI where such follow-up changes
are rejected and not retried, leaving the cluster in an unexpected state
for the testcase.

An example is with
`quorum_queue_SUITE:force_shrink_member_to_current_member/1`
2024-11-28 11:27:40 +01:00
Michal Kuratczyk 46259b5a48
Fix invalid warning about transient queues being used
This fixes the issue where RabbitMQ would warn about
transient queues being used in a cluster with no transient queues.

Fixes https://github.com/rabbitmq/rabbitmq-server/issues/12802
2024-11-27 22:04:01 +01:00
Michal Kuratczyk 1552f89dd7
Skip are_transient_nonexcl_used check on virin node
This check fails on a virin node, because the metadata store
is not yet ready to handle the query. However, a virin
node by definition can't have any queues, so let's just return
false without asking.
2024-11-27 22:03:53 +01:00
Michael Klishin 1cae417dbf
Merge pull request #12821 from rabbitmq/rabbitmq-server-12776
Definition export: inject default queue type into virtual host metadata
2024-11-27 14:53:25 -05:00
Michael Klishin 8a5ea76fe4
Inject DQT into 'ctl export_definitions' 2024-11-27 12:29:48 -05:00
Diana Parra Corbacho d004d69200 Tests: feature_flags_v2_SUITE ignore peer:stop/1 return value 2024-11-27 15:45:58 +01:00
Michael Klishin 090d11818f
HTTP API tests for injected default queue type 2024-11-26 18:00:37 -05:00
Michael Klishin 51e6004840
Inject DQT into GET /api/definitions and /api/vhosts
References #12776
2024-11-26 02:04:30 -05:00
Jean-Sébastien Pédron f6314d06b3
rabbit_peer_discovery: Retry RPC calls
[Why]
In CI, we observe some timeouts in the Erlang distribution connections
between the temporary hidden node and the nodes it queries. This affects
peer discovery obviously.

[How]
We introduce some query retries to reduce the risk of an incomplete
query.

While here, we move the sorting of queried nodes from the
`query_node_props2/3` last clause (executed in the temporary hidden
node) to the function setting the temporary hidden node and asking for
these queries. This way the debug messages from that sorting are logged
by RabbitMQ out of the box.
2024-11-25 16:16:16 +01:00
Jean-Sébastien Pédron 4d4985f254
rabbit_peer_discovery: Fix non-tail-recursive `query_node_props2()`
[Why]
This impacts what is reported by the catch because it caught exceptions
emitted by code supposedly called later. An example is the assert
in `query_node_props2/3` last clause.
2024-11-25 16:16:15 +01:00
Jean-Sébastien Pédron 62f22a7655
rabbit_peer_discovery: Remove the use of group leader proxy
[Why]
This was the first solution put in place to prevent that the temporary
hidden node connects to the node that started it to write any printed
messages. Because of this, the nodes that the temporary hidden node
queried found out about the parent node and they opened an Erlang
distribution connection to it. This polluted the known nodes list.

However later, the temporary hidden node was started with the
`standard_io` connection option. This prevented the temporary hidden
node from knowing about the node that started it, solving the problem in
a cleaner way.

[How]
This commit garbage-collects that piece of code that is now useless. It
makes the query code way simpler to understand.
2024-11-25 16:16:12 +01:00
D Corbacho 1fa4fe2735
Merge pull request #12775 from rabbitmq/fix-flakes
Fixes for test flakes
2024-11-25 16:12:29 +01:00
Jean-Sébastien Pédron fe2061b13b
quorum_queue_member_reconciliation_SUITE: Improve `reset_nodes/2`
[How]
The function now accepts that the node to reset is already out of the
cluster. This avoids a mismatch exception for a situation that is ok.
2024-11-25 12:55:26 +01:00
Jean-Sébastien Pédron 03f9d36988
rabbit_vhosts: Don't reconcile vhosts if `rabbit` is stopped
[Why]
That timer was started during boot and continued regardless if `rabbit`
was running or stopped.

This caused the reconsiliation to crash if the `rabbit` app was stopped
before the it ended because it tried to access the database even though
it was stopped or even reset.

[How]
We just check if `rabbit` is running before running one reconciliation
and scheduling a new one.
2024-11-25 12:39:13 +01:00
Diana Parra Corbacho 73924ba08e Tests: amqp_client_SUITE delete all queues on end per testcase 2024-11-25 09:06:33 +01:00
Diana Parra Corbacho a35f56fdc2 Tests: amqp_filtex_SUITE wait for link attachment and longer timeouts 2024-11-25 09:06:32 +01:00
GitHub 4e8d0f3ac2 bazel run gazelle 2024-11-23 04:02:38 +00:00
Michael Davis c3c7675bda
rabbit_khepri: Add macros for path patterns 2024-11-22 11:21:11 -05:00
Michael Davis e8fb9b6889
rabbit: Move include/{khepri.hrl => rabbit_khepri.hrl}
This fixes erlang_ls's header resolution. Previously it would confuse
the include_lib of the `khepri.hrl` from Khepri with this header in
the rabbit app.

This header is also specific to how rabbit uses Khepri so I think the
new name fits better.
2024-11-22 11:21:11 -05:00
Michael Klishin ea58fb1b48
crashing_queues_SUITE: squash a compiler warning 2024-11-17 17:23:00 -05:00
Michael Klishin 9f026f7a4b
Merge pull request #12727 from rabbitmq/rabbitmq-server-12709
By @Ayanda-D: Ensure only alive leaders and followers when fetching QQ replica states
2024-11-15 13:53:41 -05:00
Ayanda Dube 53cc8f8f2b
Update unit_quorum_queue_SUITE to use temporary alive & registered
test queue processes (since we now check/return only alive members
when fetching replica states)

(cherry picked from commit ebc0387b81)
2024-11-15 12:49:55 -05:00
David Ansari 6e8b566323 Deduplicate AMQP type inference
Introduce a single place in the AMQP 1.0 Erlang client that infers the AMQP 1.0 type.

Erlang integers are inferred to be AMQP type `long` to avoid overflow surprises.
2024-11-15 17:40:36 +01:00
Jean-Sébastien Pédron 2938338182
rabbit_khepri: Do not hard-code `coordination`, use the constant instead 2024-11-15 16:41:16 +01:00
Jean-Sébastien Pédron 05717ccccf
rabbit_khepri: Remove serial file during reset 2024-11-15 16:40:50 +01:00
Jean-Sébastien Pédron e41d766b29
rabbit_khepri: Ensure RabbitMQ is stopped before resetting with Khepri 2024-11-15 16:40:45 +01:00
Jean-Sébastien Pédron 7e2e7b79f2
rabbit_feature_flags: Support relative setting in `forced_feature_flags_on_init`
[Why]
We already support that from the environment variable, it is easy to add
to the configuration setting.
2024-11-15 14:50:35 +01:00
Michael Klishin 3e509c9f30
Merge pull request #12714 from rabbitmq/amqp-event-exchange
Support publishing AMQP 1.0 to Event Exchange
2024-11-14 18:09:19 -05:00
Ayanda Dube 3ecb3b61d4
Use whereis/1 instead of rabbit_process helper, and lists:filtermap/2 in
rabbit_quorum_queue:all_replica_states/0

(cherry picked from commit 19cc2d0608)
2024-11-14 14:05:17 -05:00
Ayanda Dube 6bb4c89c71
Add test for rabbit_quorum_queue:all_replica_states/0
and ensure non-existent/inactive/noproc QQ members are
not reported.

(cherry picked from commit 4e2c62b6af)
2024-11-14 14:05:12 -05:00
Ayanda Dube 9070e394d3
Ensure only alive QQ replica states are reported
when checking replica states to help avoid missing
inactive replicas e.g. on QQ checks from cli tools

(cherry picked from commit 491485092c)
2024-11-14 14:05:08 -05:00
Michael Klishin 15d3d5a8a1
Merge pull request #12674 from rabbitmq/add-is_feature_used-callback-to-transient_nonexcl_queues-depr-feature
rabbit_amqqueue: Add `is_feature_used` callback to `transient_nonexcl_queues` depr. feature
2024-11-14 13:57:32 -05:00
Michael Klishin c888689cca
Merge pull request #12722 from rabbitmq/fix-flakes
Fix flakes
2024-11-14 13:36:17 -05:00
Loïc Hoguin db50739ad8
CQ: Fix flakes in the store file scan test
We don't expect random bytes to be there in the current
version of the message store as we overwrite empty spaces
with zeroes when moving messages around.

We also don't expect messages to be false flagged when
the broker is running because it checks for message
validity in the index. Therefore make sure message bodies
in the tests don't contain byte 255.
2024-11-14 15:04:49 +01:00
Diana Parra Corbacho 6e7269994d Tests: per_node_limit_SUITE cleanup
Catch exceptions when closing connections during cleanup
2024-11-14 15:02:47 +01:00
Diana Parra Corbacho 5ef4fba851 tests: amqp_client_SUITE longer wait on receive for CI 2024-11-14 15:02:47 +01:00
Diana Parra Corbacho 2d025b579b Tests: amqpl_consumer_ack use unmanaged connection 2024-11-14 15:02:47 +01:00
David Ansari de804d1fa7 Support publishing AMQP 1.0 to Event Exchange
## What?

Prior to this commit, the `rabbitmq_event_exchange` internally published
always AMQP 0.9.1 messages to the `amq.rabbitmq.event` topic exchange.
This commit allows users to configure the plugin to publish AMQP 1.0
messages instead.

 ## Why?

Prior to this commit, when an AMQP 1.0 client consumed events,
event properties that are lists were omitted. For example property
`client_properties` of event `connection.created` or property
`arguments` of event `queue.created` were omitted because of the following sequence:
1. The event exchange plugins listens for all kind of internal events.
2. The event exchange plugin re-publishes all events as AMQP 0.9.1 message to the event exchange.
3. Later, when an AMQP 1.0 client consumes this message, the broker must translate the message from AMQP 0.9.1 to AMQP 1.0.
4. This translation follows the rules outlined in https://www.rabbitmq.com/docs/conversions#amqpl-amqp
5. Specifically, in this table the row before the last one describes the rule we're hitting here. It says that if the AMQP 0.9.1
header value is not an `x-` prefixed header and its value is an array or table, then this header is not converted.
That's because AMQP 1.0 application-properties must be simple types as mandated in https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-application-properties

 ## How?

The user can configure the plugin as follows to have the plugin
internally publish AMQP 1.0 messages:
```
event_exchange.protocol = amqp_1_0
```

To support complex types such as lists, the plugin sets all event
properties as AMQP 1.0 message-annotations. The plugin prefixes all message
annotation keys with `x-opt-` to comply with the AMQP 1.0 spec.

 ## Alternative Design

An alternative design would have been to format all event properties
e.g. as JSON within the message body. However, this breaks routing on
specific event property values via a headers exchange.

 ## Documentation
https://github.com/rabbitmq/rabbitmq-website/pull/2129
2024-11-14 12:52:09 +01:00
Karl Nilsson bfa293ab3b QQ: reduce memory use when dropping many messages at once.
As may happen when a max_length configuration change is made
when there are many messages on the queue.
2024-11-13 09:07:40 +00:00
Michael Klishin aba62b9d12
Mention node_tags #12702 in rabbitmq.conf.example 2024-11-11 22:56:47 -05:00
Simon Unge 3d35416635 Node tags local to broker, add to /api/overview output and ctl status command 2024-11-11 20:49:21 +00:00
Jean-Sébastien Pédron 638e3a4b08
rabbit_amqqueue: Add `is_feature_used` callback to `transient_nonexcl_queues` depr. feature
[Why]
Without this callback, the deprecated features subsystem can't report if
the feature is used or not.

This reduces the usefulness of the HTTP API endpoint or the CLI command
that help verify if a cluster is using deprecated features.

[How]
The callback counts transient non-exclusive queues and return `true` if
there are one or more of them.

References #12619.
2024-11-11 15:57:52 +01:00
Michael Klishin b43a7263f5
List cluster_tags in rabbitmq.conf.example #12552 #12659 #12699 2024-11-10 20:26:24 -05:00
Michael Klishin f5801be6db
Merge pull request #12659 from rabbitmq/su_aws/cluster_tag
Make it possible to set some cluster metadata besides the name using tags
2024-11-10 19:17:53 -05:00
Michael Klishin 7c66fba0c3
Make it possible to clear cluster_tags via rabbitmq.conf 2024-11-10 14:38:34 -05:00
Michael Klishin 9e649aefc0
We no longer use 'maybe' in this module 2024-11-10 14:35:14 -05:00
Michael Klishin e5d805ea6d
Cluster tags: set unconditionally
Otherwise once set, it would not be possible
to change them by updating rabbitmq.conf
2024-11-10 14:30:51 -05:00
Michael Klishin 6b614fc879
rabbitmq.conf.example: add management.http.max_body_size 2024-11-09 18:02:16 -05:00
Simon Unge eeea517da5 Store tags in global parameters 2024-11-08 21:41:49 +00:00
Simon Unge f5ef64ad06 Add cluster tag config that is exposed via HTTP /api/overview and CTL cluster_status 2024-11-08 21:05:02 +00:00
Arnaud Cogoluègnes ca70f20bca
Merge pull request #12686 from rabbitmq/stream-coordinator-ra-local-query-infinity-timeout
Use infinity timout for RA local query in stream coordinator
2024-11-08 15:08:16 +01:00
David Ansari c839409599 Fix test flake properties_section
This test flaked in CI with the following error:
```
=== === Reason: no match of right hand side value {error,half_attached}
  in function  amqp_utils:detach_link_sync/1 (amqp_utils.erl, line 100)
  in call from amqp_filtex_SUITE:properties_section/1 (amqp_filtex_SUITE.erl, line 187)
  in call from test_server:ts_tc/3 (test_server.erl, line 1793)
  in call from test_server:run_test_case_eval1/6 (test_server.erl, line 1302)
  in call from test_server:run_test_case_eval/9 (test_server.erl, line 1234)
```
2024-11-08 11:46:19 +01:00
David Ansari 9095f7d961 Fix test flake
Increase waiting for credit being applied as described in commit
aeedad7b51 since this test case still flakes rarely with:
```
=== === Reason: {assertEqual,[{module,amqp_client_SUITE},
                               {line,3030},
                               {expression,"amqp10_msg : body ( Msg1 )"},
                               {expected,[<<"1">>]},
                               {value,[<<"2">>]}]}
  in function  amqp_client_SUITE:detach_requeues_two_connections/2 (amqp_client_SUITE.erl, line 3030)
  in call from test_server:ts_tc/3 (test_server.erl, line 1793)
  in call from test_server:run_test_case_eval1/6 (test_server.erl, line 1302)
  in call from test_server:run_test_case_eval/9 (test_server.erl, line 1234)
```
2024-11-08 11:35:04 +01:00
Arnaud Cogoluègnes 1634adbff3
Use infinity timout for RA local query in stream coordinator
The 5-second default timeout is too short.
2024-11-08 09:26:24 +01:00
David Ansari 124ef694bc Fix crashes
This commit fixes two different bugs/crashes.

To repro, prior to this commit:
1. Create an AMQP 1.0 connection on node-1.
2. Open the Management UI on node-2 and open the connection page of this
   single AMQP 1.0 connection.

The first crash was the following:
```
[error] <0.1297.0>   crasher:
[error] <0.1297.0>     initial call: cowboy_stream_h:request_process/3
[error] <0.1297.0>     pid: <0.1297.0>
[error] <0.1297.0>     registered_name: []
[error] <0.1297.0>     exception error: no case clause matching
[error] <0.1297.0>                      {badrpc,
[error] <0.1297.0>                          {'EXIT',
[error] <0.1297.0>                              {undef,
[error] <0.1297.0>                                  [{rabbit_connection_tracking,lookup,
[error] <0.1297.0>                                       [<<"[::1]:51729 -> [::1]:5672">>,
[error] <0.1297.0>                                        ['rabbit-1@ABCDDDEEAA']],
[error] <0.1297.0>                                       []}]}}}
[error] <0.1297.0>       in function  rabbit_connection_tracking:lookup/2 (rabbit_connection_tracking.erl, line 235)
[error] <0.1297.0>       in call from rabbit_mgmt_wm_connection_sessions:conn/1 (rabbit_mgmt_wm_connection_sessions.erl, line 72)
[error] <0.1297.0>       in call from rabbit_mgmt_wm_connection_sessions:is_authorized/2 (rabbit_mgmt_wm_connection_sessions.erl, line 63)
[error] <0.1297.0>       in call from cowboy_rest:call/3 (src/cowboy_rest.erl, line 1590)
[error] <0.1297.0>       in call from cowboy_rest:is_authorized/2 (src/cowboy_rest.erl, line 368)
[error] <0.1297.0>       in call from cowboy_rest:upgrade/4 (src/cowboy_rest.erl, line 284)
[error] <0.1297.0>       in call from cowboy_stream_h:execute/3 (src/cowboy_stream_h.erl, line 306)
[error] <0.1297.0>       in call from cowboy_stream_h:request_process/3 (src/cowboy_stream_h.erl, line 295)
```

The second crash was the following:
```
[error] <0.1132.0>   crasher:
[error] <0.1132.0>     initial call: cowboy_stream_h:request_process/3
[error] <0.1132.0>     pid: <0.1132.0>
[error] <0.1132.0>     registered_name: []
[error] <0.1132.0>     exception error: no case clause matching
[error] <0.1132.0>                      {tracked_connection,
[error] <0.1132.0>                          {'rabbit-1@ABCDDDEEAA',
[error] <0.1132.0>                              <<"[::1]:65505 -> [::1]:5672">>},
[error] <0.1132.0>                          'rabbit-1@ABCDDDEEAA',<<"/">>,
[error] <0.1132.0>                          <<"[::1]:65505 -> [::1]:5672">>,<13661.1110.0>,
[error] <0.1132.0>                          {1,0},
[error] <0.1132.0>                          network,
[error] <0.1132.0>                          {0,0,0,0,0,0,0,1},
[error] <0.1132.0>                          65505,<<"guest">>,1730908606089}
[error] <0.1132.0>       in function  rabbit_connection_tracking:lookup/2 (rabbit_connection_tracking.erl, line 235)
[error] <0.1132.0>       in call from rabbit_mgmt_wm_connection_sessions:conn/1 (rabbit_mgmt_wm_connection_sessions.erl, line 72)
[error] <0.1132.0>       in call from rabbit_mgmt_wm_connection_sessions:is_authorized/2 (rabbit_mgmt_wm_connection_sessions.erl, line 63)
[error] <0.1132.0>       in call from cowboy_rest:call/3 (src/cowboy_rest.erl, line 1590)
[error] <0.1132.0>       in call from cowboy_rest:is_authorized/2 (src/cowboy_rest.erl, line 368)
[error] <0.1132.0>       in call from cowboy_rest:upgrade/4 (src/cowboy_rest.erl, line 284)
[error] <0.1132.0>       in call from cowboy_stream_h:execute/3 (src/cowboy_stream_h.erl, line 306)
[error] <0.1132.0>       in call from cowboy_stream_h:request_process/3 (src/cowboy_stream_h.erl, line 295)
2024-11-07 15:11:42 +01:00
David Ansari 9d0c851df2 Show session and link details for AMQP 1.0 connection
## What?

On the connection page in the Management UI, display detailed session and
link information including:
* Link names
* Link target and source addresses
* Link flow control state
* Session flow control state
* Number of unconfirmed and unacknowledged messages

 ## How?

A new HTTP API endpoint is added:
```
/connections/:connection_name/sessions
```

The HTTP handler first queries the Erlang connection process to find out about
all session Pids. The handler then queries each Erlang session process
of this connection.

(The table auto-refreshes by default every 5 seconds. The handler querying a single
connection with 60 idle sessions with each 250 links takes ~100 ms.)

For better user experience in the Management UI, this commit also makes the
session process store and expose link names as well as source/target addresses.
2024-11-07 15:11:42 +01:00
Jean-Sébastien Pédron d2d608211a
rabbit_feature_flags: Use non-blocking call in `get_state/1`
[Why]
The previous implementation was using the blocking `is_enabled/1` API.
This meant that if a feature flag was being enabled and the enable
callback took time, the CLI's `list_feature_flag` command or any use of
the management UI would block until the feature flag was enabled.

[How]
`get_state/1` now uses the non-blocking API. However it returns a now
possible value: `state_changing`.
2024-11-06 11:35:14 +01:00
Jean-Sébastien Pédron f90cb869cc
rabbit_feature_flags: Expose more feature flag properties to the management API
[Why]
It allows to better communicate each feature flag specificities and make
a better more user-friendly management UI.
2024-11-06 11:35:14 +01:00
Jean-Sébastien Pédron 724705ca3b
rabbit_feature_flags: Declare if an experimental feature flag is supported or not
[Why]
Durint the development of Khepri, it was difficult to communicate that
it was unsupported in RabbitMQ 3.13.x but was then supported in 4.0.x
even though it was still experimental.

[How]
The feature flag definition now exposes that support level in a now
attribute called `experiment_level`. It can be `unsupported` or
`supported`.

We can use this now attribute in the CLI or the web UI to convey the
level of support to the end user.

In the future, we could imagine that an experimental feature flag
becomes abandoned, where upgraded from a node that has it enabled to a
version that marks the feature flag as abandoned is not possible.
2024-11-06 11:35:14 +01:00
Lois Soto Lopez 4819801a33 Exclude policy_repair QQ test on mixed versions 2024-11-05 16:38:18 +01:00
GitHub 71bdd1a78c bazel run gazelle 2024-11-05 04:02:22 +00:00
Michael Klishin 508ec97c88
Merge pull request #12646 from rabbitmq/metrics-flakes
metrics_SUITE: wait for tables in proper test
2024-11-04 12:08:26 -05:00
David Ansari 6034f3c411
Merge pull request #12638 from rabbitmq/amqp-connection-metrics
Expose AMQP connection metrics
2024-11-04 17:57:29 +01:00
Diana Parra Corbacho 054fcd676c metrics_SUITE: wait for tables in proper test 2024-11-04 16:46:23 +01:00
Michael Klishin 734f6853bc
Merge branch 'main' into rabbitmq-server-12412 2024-11-04 00:39:51 -05:00
Michael Klishin 8ea7e65e34
QQ: handle case where a stale read request results in member crash.
It is possible for a slow running follower with local consumers
to crash after a snapshot installation as it tries to read an entry
from its log that is no longer there (as it has been consumed and
completed by another node but still refers to prior consumers on the
current node).

This commit makes the log effect callback function more defensive
to check that the number of commands returned by the log effect
isn't different from what was requested. if it is different we
consider this a stale read request and return no further effects.

Conflicts:
	deps/rabbit/test/quorum_queue_SUITE.erl
2024-11-04 00:36:48 -05:00
David Ansari af876ed6d1
Use log macros for AMQP
Using a log macro has the benefit that location data is added as
explained in https://www.erlang.org/doc/apps/kernel/logger.html#t:metadata/0
2024-11-04 00:34:51 -05:00
David Ansari 6fde076707
Support AMQP 1.0 token renewal
Closes #9259.

 ## What?
Allow an AMQP 1.0 client to renew an OAuth 2.0 token before it expires.

 ## Why?
This allows clients to keep the AMQP connection open instead of having
to create a new connection whenever the token expires.

 ## How?
As explained in https://github.com/rabbitmq/rabbitmq-server/issues/9259#issuecomment-2437602040
the client can `PUT` a new token on HTTP API v2 path `/auth/tokens`.
RabbitMQ will then:
1. Store the new token on the given connection.
2. Recheck access to the connection's vhost.
3. Clear all permission caches in the AMQP sessions.
4. Recheck write permissions to exchanges for links publishing to
   RabbitMQ, and recheck read permissions from queues for links
   consuming from RabbitMQ. The latter complies with the user
   expectation in #11364.
2024-11-04 00:34:51 -05:00
Diana Parra Corbacho ff44f4d355
Test: metrics_SUITE queue_idemp wait for queue metrics 2024-11-04 00:34:51 -05:00
Diana Parra Corbacho ab9d225502
Tests: wait for connection closed in metrics_SUITE 2024-11-04 00:34:50 -05:00
Jean-Sébastien Pédron fe7beea4b8
rabbit_feature_flags: Log controller task on a single line 2024-11-04 00:34:50 -05:00
Jean-Sébastien Pédron 9802348683
rabbit_feature_flags: Report feature flags init error reason
[Why]
`failed_to_initialize_feature_flags_registry` was a little too vague.
2024-11-04 00:34:50 -05:00
Jean-Sébastien Pédron 937ca915c9
rabbit_feature_flags: Introduce hard vs. soft required feature flags
[Why]
Before this patch, required feature flags were basically checked during
boot: they must have been enabled when they were mere stable feature
flags. If they were not, the node refused to boot.

This was easy for the developer because making a feature flag required
allowed to remove the entire compatibility code. Very satisfying.

Unfortunately, this was a pain point to end users, especially those who
did not pay attention to RabbitMQ and the release notes and were just
asking their package manager to update everything. They could end up
with a node that refuse to boot. The only solution was to downgrade,
enable the disabled stable feature flags, upgrade again.

[How]
This patch introduces two levels of requirement to required feature
flags:
* `hard`: this corresponds to the existing behavior where a node will
  refuse to boot if a hard required feature flag is not enabled before
  the upgrade.
* `soft`: such a required feature flag will be automatically enabled
  during the upgrade to a version where it is marked as required.

The level of requirement is set in the feature flag definition:

    -rabbit_feature_flag(
       {my_feature_flag,
        #{stability     => required,
	  require_level => hard
         }}).

The default requirement level is `soft`. All existing required feature
flags have now a requirement level of `hard`.

The handling of soft required feature flag is done when the cluster
feature flags states are verified and synchronized. If a required
feature flag is not enabled yet, it is enabled at that time.

This means that as developers, we will have to keep compatibility code
forever for every soft required feature flag, like the feature flag
definition itself.
2024-11-04 00:34:49 -05:00
Diana Parra Corbacho ef06f80bb8
Fix metrics_SUITE connection_metrics flake 2024-11-04 00:34:48 -05:00
Loïc Hoguin 2235492d28
Make CI: Add mixed version testing
This is enabled on main and for pull requests. Bazel remains
used in previous branches.
2024-11-04 00:34:47 -05:00
David Ansari 238ce77585
Delete test access_failure
This test flakes in CI as described in
https://github.com/rabbitmq/rabbitmq-server/issues/12413#issuecomment-2419293869

The test case fails with
```
Node: rabbit_shard2@localhost
Case: amqp_system_SUITE:access_failure
Reason: {error,{{badmatch,{error,134,
                                 "Unhandled exception. System.Exception: expected exception not received
                                 at Program.Test.accessFailure(String uri) in /home/runner/work/rabbitmq-server/rabbitmq-server/deps/rabbit/test/amqp_system_SUITE_data/fsharp-tests/Program.fs:line 477
                                 at Program.main(String[] argv) in /home/runner/work/rabbitmq-server/rabbitmq-server/deps/rabbit/test/amqp_system_SUITE_data/fsharp-tests/Program.fs:line 509\n"}},
                [{amqp_system_SUITE,run_dotnet_test,2,
                                    [{file,"amqp_system_SUITE.erl"},
                                     {line,257}]},
```

However, RabbitMQ closes the session as expected due to the missing read
permissions to the queue as shown in the RabbitMQ logs:
```
[debug] <0.1321.0> Asked to create a new user 'access_failure', password length in bytes: 24
[info] <0.1321.0> Created user 'access_failure'
[debug] <0.1324.0> Asked to set permissions for user 'access_failure' in virtual host '/' to '.*', '^banana.*', '^banana.*'
[info] <0.1324.0> Successfully set permissions for user 'access_failure' in virtual host '/' to '.*', '^banana.*', '^banana.*'
[info] <0.1333.0> accepting AMQP connection 127.0.0.1:36248 -> 127.0.0.1:25000
[debug] <0.1333.0> User 'access_failure' authenticated successfully by backend rabbit_auth_backend_internal
[info] <0.1333.0> Connection from AMQP 1.0 container 'AMQPNetLite-101d7d51': user 'access_failure' authenticated using SASL mechanism PLAIN and granted access to vhost '/'
[debug] <0.1333.0> AMQP 1.0 connection.open frame: hostname = 127.0.0.1, extracted vhost = /, idle-time-out = undefined
[debug] <0.1333.0> AMQP 1.0 created session process <0.1338.0> for channel number 0
[warning] <0.1338.0> Closing session for connection <0.1333.0>: {'v1_0.error',
[warning] <0.1338.0>                                             {symbol,
[warning] <0.1338.0>                                              <<"amqp:unauthorized-access">>},
[warning] <0.1338.0>                                             {utf8,
[warning] <0.1338.0>                                              <<"read access to queue 'test' in vhost '/' refused for user 'access_failure'">>},
[warning] <0.1338.0>                                             undefined}
[debug] <0.1333.0> AMQP 1.0 closed session process <0.1338.0> with channel number 0
[warning] <0.1333.0> closing AMQP connection <0.1333.0> (127.0.0.1:36248 -> 127.0.0.1:25000, duration: '269ms'):
[warning] <0.1333.0> client unexpectedly closed TCP connection
```

```
let receiver = ReceiverLink(ac.Session, "test-receiver", src)
```
uses a null constructur for the onAttached callback.
ReceiverLink doesn't seem to block.

Given that the exact same authorization error is already tested in test
case attach_source_queue of amqp_auth_SUITE, it's safe to delete this F#
test.
2024-11-04 00:34:47 -05:00
David Ansari 52b6419876
Remove test flake
Prior to this commit tests
* leader_transfer_quorum_queue_credit_single
* leader_transfer_quorum_queue_credit_batches
flaked in CI during 4.1 (main) and 4.0 mixed version testing.

The follwing error occurred on node 0:
```
[error] <0.1950.0> Timed out waiting for credit reply from quorum queue 'leader_transfer_quorum_queue_credit_batches' in vhost '/'. Hint: Enable feature flag rabbitmq_4.0.0
[warning] <0.1950.0> Closing session for connection <0.1945.0>: {'v1_0.error',
[warning] <0.1950.0>                                             {symbol,<<"amqp:internal-error">>},
[warning] <0.1950.0>                                             {utf8,
[warning] <0.1950.0>                                              <<"Timed out waiting for credit reply from quorum queue 'leader_transfer_quorum_queue_credit_batches' in vhost '/'. Hint: Enable feature flag rabbitmq_4.0.0">>},
[warning] <0.1950.0>                                             undefined}
```

Therefore we enable this feature flag for both tests.

This commit also simplifies some test setups that were necessary for
4.0/3.13 mixed version testing, but isn't necessary anymore for 4.1/4.0
mixed version testing.
2024-11-04 00:34:47 -05:00
David Ansari 70597737e4
Support x-cc message annotation (#12559)
Support x-cc message annotation

Support an `x-cc` message annotation in AMQP 1.0
similar to the [CC](https://www.rabbitmq.com/docs/sender-selected) header in AMQP 0.9.1.

The value of the `x-cc` message annotation must by a list of strings.
A message annotation is used since application properties allow only simple types.
2024-11-04 00:34:47 -05:00
David Ansari 9c2ee91a3c
Validate setting permissions works
in order to troubleshoot the flake described in
https://github.com/rabbitmq/rabbitmq-server/issues/12413#issuecomment-2419293869
```
Node: rabbit_shard2@localhost
Case: amqp_system_SUITE:access_failure
Reason: {error,{{badmatch,{error,134,
                                 "Unhandled exception. System.Exception: expected exception not received\n
                                 at Program.Test.accessFailure(String uri) in /home/runner/work/rabbitmq-server/rabbitmq-server/deps/rabbit/test/amqp_system_SUITE_data/fsharp-tests/Program.fs:line 477\n
                                 at Program.main(String[] argv) in /home/runner/work/rabbitmq-server/rabbitmq-server/deps/rabbit/test/amqp_system_SUITE_data/fsharp-tests/Program.fs:line 509\n"}},
                [{amqp_system_SUITE,run_dotnet_test,2,
                                    [{file,"amqp_system_SUITE.erl"},
                                     {line,257}]},
```
2024-11-04 00:34:46 -05:00
David Ansari 3db4a97cfb Expose AMQP connection metrics
Expose the same metrics for AMQP 1.0 connections as for AMQP 0.9.1 connections.

Display the following AMQP 1.0 metrics on the Management UI:
* Network bytes per second from/to client on connections page
* Number of sessions/channels on connections page
* Network bytes per second from/to client graph on connection page
* Reductions graph on connection page
* Garbage colletion info on connection page

Expose the following AMQP 1.0 per-object Prometheus metrics:
* rabbitmq_connection_incoming_bytes_total
* rabbitmq_connection_outgoing_bytes_total
* rabbitmq_connection_process_reductions_total
* rabbitmq_connection_incoming_packets_total
* rabbitmq_connection_outgoing_packets_total
* rabbitmq_connection_pending_packets
* rabbitmq_connection_channels

The rabbit_amqp_writer proc:
* notifies the rabbit_amqp_reader proc if it sent frames
* hibernates eventually if it doesn't send any frames

The rabbit_amqp_reader proc:
* does not emit stats (update ETS tables) if no frames are received
or sent to save resources when there are many idle connections.
2024-11-02 19:08:24 +01:00
Karl Nilsson 94e677987f QQ: handle case where a stale read request results in member crash.
It is possible for a slow running follower with local consumers
to crash after a snapshot installation as it tries to read an entry
from its log that is no longer there (as it has been consumed and
completed by another node but still refers to prior consumers on the
current node).

This commit makes the log effect callback function more defensive
to check that the number of commands returned by the log effect
isn't different from what was requested. if it is different we
consider this a stale read request and return no further effects.
2024-11-01 11:37:20 +00:00
Michael Klishin 67bc9504ed
Merge pull request #12617 from rabbitmq/amqp-log-macro
Use log macros for AMQP
2024-10-31 14:25:42 -04:00
Diana Parra Corbacho 0df71d54cb Test: metrics_SUITE queue_idemp wait for queue metrics 2024-10-31 09:39:44 +01:00
Diana Parra Corbacho 34c1fd13d9 Tests: wait for connection closed in metrics_SUITE 2024-10-31 09:05:30 +01:00
David Ansari dbd9ede67b Use log macros for AMQP
Using a log macro has the benefit that location data is added as
explained in https://www.erlang.org/doc/apps/kernel/logger.html#t:metadata/0
2024-10-30 14:50:05 +01:00
Jean-Sébastien Pédron 3c15d7e3e6
rabbit_feature_flags: Log controller task on a single line 2024-10-30 11:12:40 +01:00
Jean-Sébastien Pédron 2abec68708
rabbit_feature_flags: Report feature flags init error reason
[Why]
`failed_to_initialize_feature_flags_registry` was a little too vague.
2024-10-30 11:12:40 +01:00
Jean-Sébastien Pédron ea899602b0
rabbit_feature_flags: Introduce hard vs. soft required feature flags
[Why]
Before this patch, required feature flags were basically checked during
boot: they must have been enabled when they were mere stable feature
flags. If they were not, the node refused to boot.

This was easy for the developer because making a feature flag required
allowed to remove the entire compatibility code. Very satisfying.

Unfortunately, this was a pain point to end users, especially those who
did not pay attention to RabbitMQ and the release notes and were just
asking their package manager to update everything. They could end up
with a node that refuse to boot. The only solution was to downgrade,
enable the disabled stable feature flags, upgrade again.

[How]
This patch introduces two levels of requirement to required feature
flags:
* `hard`: this corresponds to the existing behavior where a node will
  refuse to boot if a hard required feature flag is not enabled before
  the upgrade.
* `soft`: such a required feature flag will be automatically enabled
  during the upgrade to a version where it is marked as required.

The level of requirement is set in the feature flag definition:

    -rabbit_feature_flag(
       {my_feature_flag,
        #{stability     => required,
	  require_level => hard
         }}).

The default requirement level is `soft`. All existing required feature
flags have now a requirement level of `hard`.

The handling of soft required feature flag is done when the cluster
feature flags states are verified and synchronized. If a required
feature flag is not enabled yet, it is enabled at that time.

This means that as developers, we will have to keep compatibility code
forever for every soft required feature flag, like the feature flag
definition itself.
2024-10-30 11:12:18 +01:00
David Ansari 1778bc22aa Support AMQP 1.0 token renewal
Closes #9259.

 ## What?
Allow an AMQP 1.0 client to renew an OAuth 2.0 token before it expires.

 ## Why?
This allows clients to keep the AMQP connection open instead of having
to create a new connection whenever the token expires.

 ## How?
As explained in https://github.com/rabbitmq/rabbitmq-server/issues/9259#issuecomment-2437602040
the client can `PUT` a new token on HTTP API v2 path `/auth/tokens`.
RabbitMQ will then:
1. Store the new token on the given connection.
2. Recheck access to the connection's vhost.
3. Clear all permission caches in the AMQP sessions.
4. Recheck write permissions to exchanges for links publishing to
   RabbitMQ, and recheck read permissions from queues for links
   consuming from RabbitMQ. The latter complies with the user
   expectation in #11364.
2024-10-30 10:42:40 +01:00
Lois Soto Lopez 2577b7e284 Remove extra keys from `gather_policy_config` out 2024-10-28 12:54:00 +01:00
Diana Parra Corbacho 4e92841a9f Fix metrics_SUITE connection_metrics flake 2024-10-25 18:07:41 +02:00
Loïc Hoguin f68fc8bb94
Make CI: Add mixed version testing
This is enabled on main and for pull requests. Bazel remains
used in previous branches.
2024-10-25 13:50:05 +02:00
David Ansari b1169d06ba Delete test access_failure
This test flakes in CI as described in
https://github.com/rabbitmq/rabbitmq-server/issues/12413#issuecomment-2419293869

The test case fails with
```
Node: rabbit_shard2@localhost
Case: amqp_system_SUITE:access_failure
Reason: {error,{{badmatch,{error,134,
                                 "Unhandled exception. System.Exception: expected exception not received
                                 at Program.Test.accessFailure(String uri) in /home/runner/work/rabbitmq-server/rabbitmq-server/deps/rabbit/test/amqp_system_SUITE_data/fsharp-tests/Program.fs:line 477
                                 at Program.main(String[] argv) in /home/runner/work/rabbitmq-server/rabbitmq-server/deps/rabbit/test/amqp_system_SUITE_data/fsharp-tests/Program.fs:line 509\n"}},
                [{amqp_system_SUITE,run_dotnet_test,2,
                                    [{file,"amqp_system_SUITE.erl"},
                                     {line,257}]},
```

However, RabbitMQ closes the session as expected due to the missing read
permissions to the queue as shown in the RabbitMQ logs:
```
[debug] <0.1321.0> Asked to create a new user 'access_failure', password length in bytes: 24
[info] <0.1321.0> Created user 'access_failure'
[debug] <0.1324.0> Asked to set permissions for user 'access_failure' in virtual host '/' to '.*', '^banana.*', '^banana.*'
[info] <0.1324.0> Successfully set permissions for user 'access_failure' in virtual host '/' to '.*', '^banana.*', '^banana.*'
[info] <0.1333.0> accepting AMQP connection 127.0.0.1:36248 -> 127.0.0.1:25000
[debug] <0.1333.0> User 'access_failure' authenticated successfully by backend rabbit_auth_backend_internal
[info] <0.1333.0> Connection from AMQP 1.0 container 'AMQPNetLite-101d7d51': user 'access_failure' authenticated using SASL mechanism PLAIN and granted access to vhost '/'
[debug] <0.1333.0> AMQP 1.0 connection.open frame: hostname = 127.0.0.1, extracted vhost = /, idle-time-out = undefined
[debug] <0.1333.0> AMQP 1.0 created session process <0.1338.0> for channel number 0
[warning] <0.1338.0> Closing session for connection <0.1333.0>: {'v1_0.error',
[warning] <0.1338.0>                                             {symbol,
[warning] <0.1338.0>                                              <<"amqp:unauthorized-access">>},
[warning] <0.1338.0>                                             {utf8,
[warning] <0.1338.0>                                              <<"read access to queue 'test' in vhost '/' refused for user 'access_failure'">>},
[warning] <0.1338.0>                                             undefined}
[debug] <0.1333.0> AMQP 1.0 closed session process <0.1338.0> with channel number 0
[warning] <0.1333.0> closing AMQP connection <0.1333.0> (127.0.0.1:36248 -> 127.0.0.1:25000, duration: '269ms'):
[warning] <0.1333.0> client unexpectedly closed TCP connection
```

```
let receiver = ReceiverLink(ac.Session, "test-receiver", src)
```
uses a null constructur for the onAttached callback.
ReceiverLink doesn't seem to block.

Given that the exact same authorization error is already tested in test
case attach_source_queue of amqp_auth_SUITE, it's safe to delete this F#
test.
2024-10-24 18:34:25 +02:00
David Ansari c476540bbc Remove test flake
Prior to this commit tests
* leader_transfer_quorum_queue_credit_single
* leader_transfer_quorum_queue_credit_batches
flaked in CI during 4.1 (main) and 4.0 mixed version testing.

The follwing error occurred on node 0:
```
[error] <0.1950.0> Timed out waiting for credit reply from quorum queue 'leader_transfer_quorum_queue_credit_batches' in vhost '/'. Hint: Enable feature flag rabbitmq_4.0.0
[warning] <0.1950.0> Closing session for connection <0.1945.0>: {'v1_0.error',
[warning] <0.1950.0>                                             {symbol,<<"amqp:internal-error">>},
[warning] <0.1950.0>                                             {utf8,
[warning] <0.1950.0>                                              <<"Timed out waiting for credit reply from quorum queue 'leader_transfer_quorum_queue_credit_batches' in vhost '/'. Hint: Enable feature flag rabbitmq_4.0.0">>},
[warning] <0.1950.0>                                             undefined}
```

Therefore we enable this feature flag for both tests.

This commit also simplifies some test setups that were necessary for
4.0/3.13 mixed version testing, but isn't necessary anymore for 4.1/4.0
mixed version testing.
2024-10-24 18:16:11 +02:00
David Ansari 2c0cdee7d2
Support x-cc message annotation (#12559)
Support x-cc message annotation

Support an `x-cc` message annotation in AMQP 1.0
similar to the [CC](https://www.rabbitmq.com/docs/sender-selected) header in AMQP 0.9.1.

The value of the `x-cc` message annotation must by a list of strings.
A message annotation is used since application properties allow only simple types.
2024-10-24 13:03:05 +02:00
David Ansari 0c905f9b17 Validate setting permissions works
in order to troubleshoot the flake described in
https://github.com/rabbitmq/rabbitmq-server/issues/12413#issuecomment-2419293869
```
Node: rabbit_shard2@localhost
Case: amqp_system_SUITE:access_failure
Reason: {error,{{badmatch,{error,134,
                                 "Unhandled exception. System.Exception: expected exception not received\n
                                 at Program.Test.accessFailure(String uri) in /home/runner/work/rabbitmq-server/rabbitmq-server/deps/rabbit/test/amqp_system_SUITE_data/fsharp-tests/Program.fs:line 477\n
                                 at Program.main(String[] argv) in /home/runner/work/rabbitmq-server/rabbitmq-server/deps/rabbit/test/amqp_system_SUITE_data/fsharp-tests/Program.fs:line 509\n"}},
                [{amqp_system_SUITE,run_dotnet_test,2,
                                    [{file,"amqp_system_SUITE.erl"},
                                     {line,257}]},
```
2024-10-24 12:34:03 +02:00
Lois Soto Lopez 9dc9f974b5 Remove ShouldLog & limit deliv. limit not set logg
Removes the usage of a ShouldLog parameter on several functions
and limits the logging of the message warning about the delivery_limit
not being set to the moment of queueDeclaration
2024-10-24 07:28:03 +02:00
Lois Soto Lopez 3b5069fdc5 Simplify publish_confirm_many 2024-10-24 07:28:03 +02:00
Lois Soto Lopez 42b58c7c01 Use wait_for_messages_ready 2024-10-24 07:28:03 +02:00
Lois Soto Lopez df14b4a9ac Use local function for ensuring qq proc dead 2024-10-24 07:28:03 +02:00
Lois Soto Lopez 51abb5c73f Consider QQs may let pass 1st overflowing msg 2024-10-24 07:28:02 +02:00
Lois Soto Lopez dc9ab1d8cf Move tests to main qq SUITE & refactor a bit 2024-10-24 07:27:47 +02:00
Péter Gömöri ccd854878b Refactoring suggestion
(some of this is just reverting to the original format to reduce the
diff against main)
2024-10-24 07:23:02 +02:00
Lois Soto Lopez ec87ef1ceb Use ra_machine_config but limit keys to check 2024-10-24 07:23:02 +02:00
Lois Soto Lopez fabe54db94 Use `ra_machine_config` to gen a comparable config
Instead of checking the values for current configuration, represented in
`rabbit_quorum_queue:handle_tick` by the `Overview` variable, against
the effective policy, just regenerate the configuration and compare with
the current configuration.
2024-10-24 07:23:02 +02:00
Lois Soto Lopez b408351d9e Add test for QQ policy repair feature 2024-10-24 07:23:02 +02:00
Lois Soto Lopez f9179d1090 Add QQ periodic policy repair 2024-10-24 07:23:02 +02:00
Simon Unge dacdeb024d Fix so that the code handles a timeout return 2024-10-23 23:12:36 +00:00
David Ansari 814d44dd82 Convert array from AMQP 1.0 to AMQP 0.9.1
Fix the following crash when an AMQP 0.9.1 client consumes an AMQP 1.0
encoded message that contains an array value in message annotations:
```
crasher:
  initial call: rabbit_channel:init/1
  pid: <0.685.0>
  registered_name: []
  exception exit: {function_clause,
                      [{mc_amqpl,to_091,
                           [<<"x-array">>,
                            {array,utf8,[{utf8,<<"e1">>},{utf8,<<"e2">>}]}],
                           [{file,"mc_amqpl.erl"},{line,737}]},
                       {mc_amqpl,'-convert_from/3-fun-3-',1,
                           [{file,"mc_amqpl.erl"},{line,168}]},
                       {lists,filtermap_1,2,
                           [{file,"lists.erl"},{line,2279}]},
                       {mc_amqpl,convert_from,3,
                           [{file,"mc_amqpl.erl"},{line,158}]},
                       {mc,convert,3,[{file,"mc.erl"},{line,332}]},
                       {rabbit_channel,handle_deliver0,4,
                           [{file,"rabbit_channel.erl"},{line,2619}]},
                       {lists,foldl_1,3,[{file,"lists.erl"},{line,2151}]},
                       {lists,foldl,3,[{file,"lists.erl"},{line,2146}]}]}
```
2024-10-22 12:16:19 +02:00
David Ansari cbe5551cf1 bazel run gazelle 2024-10-20 12:41:23 +02:00
David Ansari dc9ebc5b81 Check topic permissions of CC and BCC headers 2024-10-20 11:41:29 +02:00
David Ansari 97512b0a9e
Merge pull request #12549 from rabbitmq/amqp-filtex-errors
Prevent crash for invalid application-properties filter
2024-10-18 17:46:03 +02:00
David Ansari c5b6e7f297 bazel run gazelle 2024-10-18 16:09:00 +02:00
David Ansari 1827df811a Prevent crash for invalid application-properties filter
application-properties keys are restricted to be strings.

Prior to this commit, a function_clause error occurred if the client
requested an invalid filter:
```
  │ *Error{Condition: amqp:internal-error, Description: Session error: function_clause
  │ [{rabbit_amqp_filtex,'-validate0/2-fun-0-',
  │                      [{{symbol,<<"subject">>},{utf8,<<"var">>}}],
  │                      [{file,"rabbit_amqp_filtex.erl"},{line,119}]},
  │  {lists,map,2,[{file,"lists.erl"},{line,2077}]},
  │  {rabbit_amqp_filtex,validate0,2,[{file,"rabbit_amqp_filtex.erl"},{line,119}]},
  │  {rabbit_amqp_filtex,validate,1,[{file,"rabbit_amqp_filtex.erl"},{line,28}]},
  │  {rabbit_amqp_session,parse_filters,2,
  │                       [{file,"rabbit_amqp_session.erl"},{line,3068}]},
  │  {rabbit_amqp_session,parse_filter,1,
  │                       [{file,"rabbit_amqp_session.erl"},{line,3014}]},
  │  {rabbit_amqp_session,'-handle_attach/2-fun-0-',21,
  │                       [{file,"rabbit_amqp_session.erl"},{line,1371}]},
  │
  {rabbit_misc,with_exit_handler,2,[{file,"rabbit_misc.erl"},{line,465}]}],
  Info: map[]}
```

After this commit, the filter won't actually take effect without a crash occurring.

Supersedes #12520
2024-10-18 15:37:28 +02:00
Michael Klishin 17dd95a801
Merge pull request #12543 from rabbitmq/su_aws/fix_desctiption_qq_target_group_size_policy
Fix module mentioned in target group size description
2024-10-18 09:01:19 -04:00
David Ansari d1d7d7bad4 Optionally notify client app with AMQP 1.0 performative
This commit notifies the client app with the AMQP performative if
connection config `notify_with_performative` is set to `true`.

This allows the client app to learn about all fields including
properties and capabilities returned by the AMQP server.
2024-10-18 13:51:35 +02:00
Simon Unge 691a0368ba Fix module mentioned in target group size description 2024-10-17 22:52:00 +00:00
Loïc Hoguin 469c3a0791
Make CI: Check that CI knows about all CT_SUITES in CI
Instead of every time we run Make for these applications.

This means that during development we are free to modify
these values or create new test suites without having to
worry about the check. If we forget to then add the test
suites in PARALLEL_CT the workflow will tell us.
2024-10-17 10:52:28 +02:00
David Ansari ab8814ad7d Fix error message
Prior to this commit if dotnet or mvnw failed to fetch test
dependencies, for example because dotnet isn't installed, the test setup
crashed in an unexpected way:
```
amqp_system_SUITE > dotnet
    {'EXIT',
        {badarg,
            [{lists,keysearch,
                 [rmq_nodes,1,
                  {skip,
                      "Failed to fetch .NET Core test project dependencies"}],
                 [{error_info,#{module => erl_stdlib_errors}}]},
             {test_server,lookup_config,2,
                 [{file,"test_server.erl"},{line,1779}]},
             {rabbit_ct_broker_helpers,get_node_configs,2,
                 [{file,"rabbit_ct_broker_helpers.erl"},{line,1411}]},
             {rabbit_ct_broker_helpers,enable_feature_flag,2,
                 [{file,"rabbit_ct_broker_helpers.erl"},{line,1999}]},
             {amqp_system_SUITE,init_per_group,2,
                 [{file,"amqp_system_SUITE.erl"},{line,77}]},
             {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1794}]},
             {test_server,run_test_case_eval1,6,
                 [{file,"test_server.erl"},{line,1391}]},
             {test_server,run_test_case_eval,9,
                 [{file,"test_server.erl"},{line,1235}]}]}}
```

This commit improves the error message instead of failing with `badarg`.

This commit also decides to fail the test setup instead of skipping the
suite because we always want CI to execute this test and be notified
instead of silently skipping if the test can't be run.
2024-10-16 17:53:17 +02:00
David Ansari 8c0cd1b78c Bump dotnet
This commit fixes the CI error on `main` branch where
amqp_system_SUITE failed with the following error:
```
Process terminated. Couldn't find a valid ICU package installed on the system. Set the configuration flag System.Globalization.Invariant to true if you want to run with no globalization support.
   at System.Environment.FailFast(System.String)
   at System.Globalization.GlobalizationMode.GetGlobalizationInvariantMode()
   at System.Globalization.GlobalizationMode..cctor()
   at System.Globalization.CultureData.CreateCultureWithInvariantData()
   at System.Globalization.CultureData.get_Invariant()
   at System.Globalization.CultureInfo..cctor()
   at System.String.ToLowerInvariant()
   at Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.GetArch()
   at Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment..cctor()
   at Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.GetRuntimeIdentifier()
   at Microsoft.DotNet.Cli.MulticoreJitProfilePathCalculator.CalculateProfileRootPath()
   at Microsoft.DotNet.Cli.MulticoreJitActivator.StartCliProfileOptimization()
   at Microsoft.DotNet.Cli.MulticoreJitActivator.TryActivateMulticoreJit()
   at Microsoft.DotNet.Cli.Program.Main(System.String[])

Exit code: 134 (pid <0.1533.0>)
```
2024-10-16 16:35:37 +02:00
David Ansari 358ff79611 Provide clear error message for reserved annotation keys
As described in https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-annotations
> The annotations type is a map where the keys are restricted to be of type symbol or of type ulong.
> All ulong keys, and all symbolic keys except those beginning with "x-" are reserved.

Prior to this commit, if an AMQP client used a reserved annotation key,
the entire AMQP connection terminated with a function_clause error
message that might be difficult to understand for client libs:
```
<<"Session error: function_clause\n[{amqp10_framing,'-decode_annotations/1-fun-0-',\n                 [{{symbol,<<\"aa\">>},{utf8,<<\"bbb\">>}}],\n                 [{file,\"amqp10_framing.erl\"},{line,158}]},\n {lists,map,2,[{file,\"lists.erl\"},{line,1559}]},\n {amqp10_framing,decode,1,[{file,\"amqp10_framing.erl\"},{line,127}]},\n {lists,map_1,2,[{file,\"lists.erl\"},{line,1564}]},\n {lists,map,2,[{file,\"lists.erl\"},{line,1559}]},\n {mc_amqp,init,1,[{file,\"mc_amqp.erl\"},{line,102}]},\n {mc,init,4,[{file,\"mc.erl\"},{line,150}]},\n {rabbit_amqp_session,incoming_link_transfer,4,\n                      [{file,\"rabbit_amqp_session.erl\"},{line,2341}]}]">>
```

This commit ends only the session and provides a clearer error message.
2024-10-16 14:14:04 +02:00
Loïc Hoguin e4d20bba51
Merge pull request #12502 from rabbitmq/loic-ct-master-patching
Make CI: Fix and enhance ct_master
2024-10-16 12:40:06 +02:00
Karl Nilsson 3b1ef8f529 QQ: fix the key_metrics_rpc function.
Currently this function always falls back to the compatibility code
and never gets the benefit of using ra:key_metrics/1 due to incorrect
use of the map update operatior ":=" instead of the insert operator
"=>".
2024-10-15 16:30:39 +01:00
Loïc Hoguin 655caf6d1a
Make CI: Have ct_master return the test results
Instead of having a CT hook just to know whether our tests failed.
2024-10-15 14:57:42 +02:00
Loïc Hoguin 6cdc32f558
Make CI: Make ct_master handle all testspec instructions 2024-10-15 14:57:42 +02:00