Commit Graph

26977 Commits

Author SHA1 Message Date
Rin Kuryloski ea895a0023 Account for Elixir containing several core applications
- eex
- elixir
- ex_unit
- iex
- logger
- mix

So that apps (like rabbitmq_cli) can dialyze against the extra
components
2023-05-12 08:26:42 +02:00
Rin Kuryloski 08061144ad Pass csv and json to rabbitmq_cli plt
So that they are no longer reported as unknown in
//deps/rabbitmq_cli:dialyze
2023-05-12 08:26:42 +02:00
Rin Kuryloski 19f4abd55b Build cli deps as .ez archives
This provides an elixir/erlang agnostic way of providing them other
erlang rules
2023-05-12 08:26:42 +02:00
Diana Parra Corbacho 6bcd73b570 Synchronise feature flags before any changes to Mnesia membership
Left as it was, a failure enabling the feature flags leaves the
cluster in an inconsistent state where the joined nodes think
the joining node is already a member, but the joining node
believes its a standalone node. Thus, later join_cluster commands
fail with an inconsistent cluster error.
2023-05-11 15:48:44 +02:00
Luke Bakken 494d171ff2
Correctly use AMQP URI query parameter `password`
Fixes #8129

The query parameter `password` in an AMQP URI should only be used to set
a certificate password, *not* the login password. The login password is
set via the `amqp_authority` section as defined here -

https://www.rabbitmq.com/uri-spec.html

* Add test that demonstrates issue in #8129
* Modify code to fix test

Modify amqp_uri so that test passes
2023-05-10 07:13:47 -07:00
Jean-Sébastien Pédron e0a2f10272
rabbit_feature_flags: Fix possible deadlock when calling the Code server
[Why]
The Feature flags registry is implemented as a module called
`rabbit_ff_registry` recompiled and reloaded at runtime.

There is a copy on disk which is a stub responsible for triggering the
first initialization of the real registry and please Dialyzer. Once the
initialization is done, this stub calls `rabbit_ff_registry` again to
get an actual return value. This is kind of recursive: the on-disk
`rabbit_ff_registry` copy calls the `rabbit_ff_registry` copy generated
at runtime.

Early during RabbitMQ startup, there could be multiple processes
indirectly calling `rabbit_ff_registry` and possibly triggering that
first initialization concurrently. Unfortunately, there is a slight
chance of race condition and deadlock:

0. No `rabbit_ff_registry` is loaded yet.
1. Both process A and B call `rabbit_ff_registry:something()` indirectly
   which triggers two initializations in parallel.
2. Process A acquires the lock first and finishes the initialization. A
   new registry is loaded and the old `rabbit_ff_registry` module copy
   is marked as "old". At this point, process B still references that
   old copy because `rabbit_ff_registry:something()` is up above in its
   call stack.
3. Process B acquires the lock, prepares the new registry and tries to
   soft-purge the old `rabbit_ff_registry` copy before loading the new
   one.

This is where the deadlock happens: process B requests the Code server
to purge the old copy, but the Code server waits for process B to stop
using it.

[How]
With this commit, process B calls `erlang:check_process_code/2` before
asking for a soft purge. If it is using an old copy, it skips the purge
because it will deadlock anyway.
2023-05-09 10:43:29 +02:00
Michael Klishin 013628db15 Pass Dialyzer 2023-05-07 21:31:36 +04:00
Michael Klishin 3835a137d6 Intentionally ignore return value here
the node is being removed
2023-05-07 21:25:04 +04:00
Michael Klishin 4da3ae0e05 Wording 2023-05-07 21:21:03 +04:00
Simon Unge 0c649b3687 See #2882. Also call quorum shrink command 2023-05-07 21:21:03 +04:00
Michael Klishin 59fe5dc01b
Prometheus: handle scenarios when no listener is configured
Start a plain TCP one with all defaults.
2023-05-06 00:19:58 +04:00
Chunyi Lyu 4ddb0c2038 Support TLS-only listener for Prometheus
- tcp listener can be turned off by setting
'prometheus.tcp.listener = none'
- config schema follows web_mqtt and web_stomp
2023-05-05 15:44:53 +01:00
Michael Klishin 64333a54ae
Merge pull request #8106 from rabbitmq/mk-bazel-run-gazelle
bazel run gazelle
2023-05-05 01:02:37 +04:00
Michael Klishin a57221d976 bazel run gazelle 2023-05-05 00:39:28 +04:00
Michael Klishin cadbb5ed42
Merge pull request #8103 from rabbitmq/mk-bump-osiris-to-1.5.1
Bump Osiris to 1.5.1
2023-05-05 00:34:24 +04:00
Michael Klishin e8ffc45cc9
Merge pull request #8098 from rabbitmq/mqtt-connection-closed-event
Add MQTT client id to connection closed event
2023-05-05 00:20:36 +04:00
Michael Klishin 2d51c8c99b Bump Osiris to 1.5.1 2023-05-05 00:09:45 +04:00
Michael Klishin bbb98226e2
Merge pull request #8100 from rabbitmq/otp26-dialyzer 2023-05-04 19:05:23 +04:00
David Ansari f296765551
Fix OTP 26 tuple dialzer warning
In OTP 26, our custom type tuple(A,B) starts intefering
with the built-in type tuple().

Therefore rename tuple(A,B) to optimised_tuple(A,B).
2023-05-04 15:31:01 +02:00
Michal Kuratczyk 1228077785
Fix rabbit_recovery_terms:start/0 return types 2023-05-04 15:31:01 +02:00
David Ansari 967e262272 Add MQTT client id to connection closed event
As requested in https://github.com/rabbitmq/rabbitmq-server/discussions/6331#discussioncomment-5796154
include all infos that were emitted in the MQTT connection created event also
in the MQTT connection closed event.
This ensures infos such as MQTT client ID are part of the connection
closed event.
Therefore, it's easy for the user to correlate between the two event
types.
Note that the MQTT plugin emits connection created and connection closed events only if
the CONNECT packet was successfully processed, i.e.authentication was successful.

Remove the disconnected_at property because it was never used.
rabbit_event already adds a timestamp to any event.
2023-05-04 09:15:55 +00:00
Michael Klishin 52b1eb9a43
Naming 2023-05-04 04:53:22 +04:00
Simon Unge d32c19e86f See #8076. Skip arg and type check on re-declare of QQ if declare type is classic. 2023-05-03 16:11:16 -07:00
Michal Kuratczyk a2bcdada3d
Don't warn about `dbg:*` functions 2023-05-02 22:44:29 +02:00
Michael Klishin bffc5d519c
Correct a couple of typos 2023-05-02 16:48:14 +04:00
Michael Klishin c9221bd717
Improve rabbitmq-queues {add,delete}_member error messages
when target queue was not found.
2023-05-02 13:28:29 +04:00
Michael Klishin d5f16d4ce6
mix format 2023-05-02 13:08:31 +04:00
Michael Klishin 7f78fc1fd8
Update a test assertion in rabbitmq_queues_cli_integration_SUITE 2023-05-02 12:59:17 +04:00
Michael Klishin e8cb0c4947
rabbitmq-queues add_member: improve error reporting 2023-05-02 12:14:48 +04:00
Michael Klishin 29d17f05cd
rabbitmq-queues add_member: extract the correct argument
during execution environment validation.
2023-05-02 12:14:26 +04:00
Michael Klishin 247452de5d
rabbitmq-queues add_member: add a missing import 2023-05-02 11:08:00 +04:00
Michael Klishin d4a2d48cea
rabbitmq-queues: validate cluster membership of the argument
Specifically of the node where new replicas should be
placed.

Closes #8007
2023-05-02 10:55:31 +04:00
Simon Unge d0fadf9e08 Fix so that default policy ha-mode and ha-sync-mode are are converted to binary 2023-05-01 14:46:05 -07:00
Loïc Hoguin e6e68fcb0b
Update Cowboy to 2.10.0 for OTP-26
We already were using Cowlib 2.12.1 and therefore were
compatible with OTP-26. This simply updates Cowboy to
the version that depends on Cowlib 2.12.1.
2023-04-28 15:34:12 +02:00
David Ansari 5ec22acd29 Ues more defensive rabbit_data_coercion:to_list/1 2023-04-28 09:19:39 +00:00
David Ansari 83eede7ef2 Keep storing MQTT client IDs as lists in Ra
Up to 3.11.x an MQTT client ID is tracked in Ra
as a list of bytes as returned by binary_to_list/1 in
48467d6e12/deps/rabbitmq_mqtt/src/rabbit_mqtt_frame.erl (L137)

This has two downsides:
1. Lists consume more memory than binaries (when tracking many clients).
2. It violates the MQTT spec which states
   "The ClientId MUST be a UTF-8 encoded string as defined in Section 1.5.3 [MQTT-3.1.3-4]." [v4 3.1.3.1]

Therefore, the original idea was to always store MQTT client IDs as
binaries starting with Native MQTT in 3.12.
However, this leads to client ID tracking misbehaving in mixed version
clusters since new nodes would register client IDs as binaries and old
nodes would register client IDs as lists. This means that a client
registering on a new node with the same client ID as a connection to the
old node did not terminate the connection on the old node.

Therefore, for backwards compatibility, we leave the client ID as a list of bytes
in the Ra machine state because the feature flag delete_ra_cluster_mqtt_node
introduced in v3.12 will delete the Ra cluster anyway and
the new client ID tracking via pg local will store client IDs as
binaries.

An interesting side note learned here is that the compiled file
rabbit_mqtt_collector must not be changed. This commit only modifies
function specs. However as soon as the compiled code is changed, this
module becomes a new version. The new version causes the anonymous ra query
function to fail in mixed clusters: When the old node does a
ra:leader_query where the leader is on the new node, the query function
fails on the new node with `badfun` because the new node does not have
the same module version. For more context, read:
https://web.archive.org/web/20181017104411/http://www.javalimit.com/2010/05/passing-funs-to-other-erlang-nodes.html
2023-04-28 07:57:23 +00:00
Simon Unge 367b1f0a6d Add ha-sync-mode as an operator policy 2023-04-27 15:16:39 -07:00
Michael Klishin 167246f5d9
Merge pull request #8003 from rabbitmq/otp26-compatibility
OTP26 compatibility
2023-04-27 17:14:34 +04:00
Loïc Hoguin 13087a09b4
Fix trust store system_SUITE for both OTP-25 and OTP-26
Due to problems with TLS 1.3 clients in OTP-25 we have to continue
using TLS 1.2 until we can drop OTP-25. Similarly, certificate
chain verification is disabled in tests (verify_none) until we
can drop OTP-25.
2023-04-27 12:08:26 +02:00
Michael Klishin 65e59f670b Only validate regular expression when the regex box is checked 2023-04-27 13:43:44 +04:00
Michael Klishin a4386db25d Wording 2023-04-27 12:32:39 +04:00
Michael Klishin fe1fbb8264 Add a warning for invalid regular expressions
Warn the user when filter expression does not compile to a regular
expression.

Part of #8008.
2023-04-27 12:27:19 +04:00
Michael Klishin a93ad3b7f1 First attempt at addressing #8008
When filter exression is not a valid regexp, send
it as a regular text filer.
2023-04-27 12:06:13 +04:00
Loïc Hoguin 948bd35343
Explicitly set verify_peer in one test to see if it fixes it 2023-04-26 18:22:02 +02:00
Loïc Hoguin 4d4310806b
Fix for OTP-26 and small refactor of system_SUITE
The test failure was caused by a certificate generated with
an insecure digest and cipher, which resulted in the client
not sending the certificate to the server.

The client will now do a CA check of the server it connects to.
The TLS version used by the client was set to the default and
will likely use TLS 1.3 now. Note that client CA verification
is unrelated to the trust store certificate verification.
2023-04-26 17:32:43 +02:00
Michal Kuratczyk 53adb6ee5d
dbg:stop_clear/0 -> dbg:stop/0
stop_clear is deprecated
2023-04-26 11:06:23 +02:00
Michal Kuratczyk 858ed1bff6
Switch to an emqtt fork/branch for OTP26
This change should be reverted once emqx/emqtt is OTP26 compatible.
Our fork/branch isn't either at this point, but at least partially
works. Let's use this branch for now to uncover server-side OTP26
incompatibilities (and continue working on OTP26 support for emqtt of
course).
2023-04-26 11:06:23 +02:00
Michael Klishin c6e69b2613 Fix a compiler warning on OTP 26, references #7845 2023-04-26 10:39:32 +04:00
Michael Klishin 331a48233b
Merge pull request #7980 from rabbitmq/lh-cqv1-ttl
CQv1: Don't limit messages in memory based on consume rate
2023-04-26 10:33:11 +04:00
Michael Klishin f1834f315f Don't use fully-qualified calls in the module itself 2023-04-26 09:52:41 +04:00