-
Notifications
You must be signed in to change notification settings - Fork 4k
MQTT and Streams: handle connection shutdown via CLI command gracefully #12118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ansd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- This PR introduces a crash as can be seen in test case
management_plugin_connectionin theshared_SUITE.
For example running
make -C deps/rabbitmq_mqtt ct-shared t=[mqtt,cluster_size_1,v5]:management_plugin_connection
will make the MQTT connection crash with:
2024-08-26 08:47:10.764564+02:00 [error] <0.1022.0> ** Reason for termination ==
2024-08-26 08:47:10.764564+02:00 [error] <0.1022.0> ** {mqtt_unexpected_msg,{shutdown,"Closed via management plugin"}}
-
This PR doesn't handle WebMQTT connections.
-
It would be nice to add a test case for this change.
-
Ideally, we refactor such that closing connections via the Management API and via the CLI command both cause the same logic to happen in RabbitMQ, i.e. cause either
castorcallfor (Web)MQTT connections.
mkuratczyk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. This solves the original problem with the exception, but I now noticed this in the logs:
2024-08-26 08:53:40.395974+02:00 [info] <0.988.0> Closing connection <0.918.0> because <<"foobar">>
2024-08-26 08:53:40.396062+02:00 [info] <0.918.0> MQTT closing connection <<"127.0.0.1:54961 -> 127.0.0.1:1883">>: <<"foobar">>
2024-08-26 08:53:40.396161+02:00 [warning] <0.988.0> Could not close connection <0.918.0> (reason: <<"foobar">>): {shutdown,
2024-08-26 08:53:40.396161+02:00 [warning] <0.988.0>
This warning is unexpected
|
Good spot. That's because |
|
Thanks. I've just seen the issue. |
|
@ansd I've restored the original |
`{shutdown, Reason}` must be handled into handle_call and not handle_info
`rabbitmqctl close_all_user_connections` calls rabbit_reader which does
a call into the process, the same as rabbitmq_management
ef7b12b to
342f29d
Compare
mkuratczyk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionality-wise I see no problems now, thanks. I'll let David comment on the implementation.
1. Only run the CLI tests on a single node cluster. The shared_SUITE is already very big. Testing the same CLI commands against node-0 on a 3-node cluster brings no benefit. 2. Move the two new CLI test cases in front of management_plugin_connection because they are similar in that all three tests close the MQTT connection. 3. There is no need to query the HTTP API for the two new CLI test cases. 4. There is no need to set keepalive in the two new CLI test cases.
1.
Prior to this commit, closing a stream connection via:
```
./sbin/rabbitmqctl close_all_user_connections guest enough
```
crashed the stream process as follows:
```
2024-08-28 13:00:18.969931+02:00 [error] <0.1098.0> crasher:
2024-08-28 13:00:18.969931+02:00 [error] <0.1098.0> initial call: rabbit_stream_reader:init/1
2024-08-28 13:00:18.969931+02:00 [error] <0.1098.0> pid: <0.1098.0>
2024-08-28 13:00:18.969931+02:00 [error] <0.1098.0> registered_name: []
2024-08-28 13:00:18.969931+02:00 [error] <0.1098.0> exception error: no function clause matching
2024-08-28 13:00:18.969931+02:00 [error] <0.1098.0> rabbit_stream_reader:open({call,
2024-08-28 13:00:18.969931+02:00 [error] <0.1098.0> {<0.1233.0>,
2024-08-28 13:00:18.969931+02:00 [error] <0.1098.0> #Ref<0.519694519.1387790337.15898>}},
2024-08-28 13:00:18.969931+02:00 [error] <0.1098.0> {shutdown,<<"enough">>},
```
This commit fixes this crash.
2.
Both CLI commands and management plugin use the same way
to close MQTT, Web MQTT, and Stream connections: They all send a message
via `Pid ! {shutdown, Reason}` to the connection.
3.
This commit avoids making `rabbit` core app to know about
'Web MQTT'.
4
This commit simplifies rabbit_mqtt_reader by avoiding another
handle_call clause
|
Thank you @dcorbacho. |
{shutdown, Reason}must be handled into handle_call and not handle_inforabbitmqctl close_all_user_connectionscalls rabbit_reader which does a call into the process, the same as rabbitmq_managementFixes #11985