Skip to content

Commit 37f0ead

Browse files
ansddumbbell
authored andcommitted
v5_SUITE: session_upgrade_v3_v5_qos1
Prior to this commit, the following test case flaked: ``` make -C deps/rabbitmq_mqtt ct-v5 t=cluster_size_1:session_upgrade_v3_v5_qos1 ``` The test case failed with: ``` {v5_SUITE,session_upgrade_v3_v5_qos,1112} {test_case_failed,Received unexpected PUBLISH payload. Expected: <<"2">> Got: <<"1">>} ``` The broker logs showed: ``` 2025-07-15 15:50:23.914152+00:00 [debug] <0.758.0> MQTT accepting TCP connection <0.758.0> (127.0.0.1:38594 -> 127.0.0.1:27005) 2025-07-15 15:50:23.914289+00:00 [debug] <0.758.0> Received a CONNECT, client ID: session_upgrade_v3_v5_qos, username: undefined, clean start: false, protocol version: 3, keepalive: 60, property names: [] 2025-07-15 15:50:23.914403+00:00 [debug] <0.758.0> MQTT connection 127.0.0.1:38594 -> 127.0.0.1:27005 picked vhost using plugin_configuration_or_default_vhost 2025-07-15 15:50:23.914480+00:00 [debug] <0.758.0> User 'guest' authenticated successfully by backend rabbit_auth_backend_internal 2025-07-15 15:50:23.914641+00:00 [info] <0.758.0> Accepted MQTT connection 127.0.0.1:38594 -> 127.0.0.1:27005 for client ID session_upgrade_v3_v5_qos 2025-07-15 15:50:23.914977+00:00 [debug] <0.758.0> Received a SUBSCRIBE with subscription(s) [{mqtt_subscription, 2025-07-15 15:50:23.914977+00:00 [debug] <0.758.0> <<"session_upgrade_v3_v5_qos">>, 2025-07-15 15:50:23.914977+00:00 [debug] <0.758.0> {mqtt_subscription_opts,1,false, 2025-07-15 15:50:23.914977+00:00 [debug] <0.758.0> false,0,undefined}}] 2025-07-15 15:50:23.924503+00:00 [debug] <0.764.0> MQTT accepting TCP connection <0.764.0> (127.0.0.1:38608 -> 127.0.0.1:27005) 2025-07-15 15:50:23.924922+00:00 [debug] <0.764.0> Received a CONNECT, client ID: session_upgrade_v3_v5_qos, username: undefined, clean start: false, protocol version: 5, keepalive: 60, property names: [] 2025-07-15 15:50:23.925589+00:00 [error] <0.758.0> writing to MQTT socket #Port<0.63> failed: closed 2025-07-15 15:50:23.925635+00:00 [debug] <0.764.0> MQTT connection 127.0.0.1:38608 -> 127.0.0.1:27005 picked vhost using plugin_configuration_or_default_vhost 2025-07-15 15:50:23.925670+00:00 [info] <0.758.0> MQTT connection <<"127.0.0.1:38594 -> 127.0.0.1:27005">> will terminate because peer closed TCP connection 2025-07-15 15:50:23.925727+00:00 [debug] <0.764.0> User 'guest' authenticated successfully by backend rabbit_auth_backend_internal 2025-07-15 15:50:24.000790+00:00 [info] <0.764.0> Accepted MQTT connection 127.0.0.1:38608 -> 127.0.0.1:27005 for client ID session_upgrade_v3_v5_qos 2025-07-15 15:50:24.016553+00:00 [warning] <0.764.0> MQTT disconnecting client <<"127.0.0.1:38608 -> 127.0.0.1:27005">> with client ID 'session_upgrade_v3_v5_qos', reason: normal ``` This shows evidence that the MQTT server connection did not process the DISCONNECT packet. The hypothesis is that the server connection did not even process the PUBACK packet from the client. Hence, the first message got requeued and re-delivered to the new v5 client. This commit fixes this flake by not acking the first message. Hence, we always expect that the first message will be redelivered to the new v5 client.
1 parent 0701edc commit 37f0ead

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

deps/rabbitmq_mqtt/test/v5_SUITE.erl

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,12 +1079,7 @@ session_upgrade_v3_v5_qos(Qos, Config) ->
10791079
{ok, _, [Qos]} = emqtt:subscribe(Subv3, Topic, Qos),
10801080
Sender = spawn_link(?MODULE, send, [self(), Pub, Topic, 0]),
10811081
receive {publish, #{payload := <<"1">>,
1082-
client_pid := Subv3,
1083-
packet_id := PacketId}} ->
1084-
case Qos of
1085-
0 -> ok;
1086-
1 -> emqtt:puback(Subv3, PacketId)
1087-
end
1082+
client_pid := Subv3}} -> ok
10881083
after ?TIMEOUT -> ct:fail("did not receive 1")
10891084
end,
10901085
%% Upgrade session from v3 to v5 while another client is sending messages.
@@ -1108,7 +1103,7 @@ session_upgrade_v3_v5_qos(Qos, Config) ->
11081103
0 ->
11091104
assert_received_no_duplicates();
11101105
1 ->
1111-
ExpectedPayloads = [integer_to_binary(I) || I <- lists:seq(2, NumSent - 1)],
1106+
ExpectedPayloads = [integer_to_binary(I) || I <- lists:seq(1, NumSent - 1)],
11121107
ok = expect_publishes(Subv5, Topic, ExpectedPayloads)
11131108
end,
11141109
ok = emqtt:disconnect(Pub),

0 commit comments

Comments
 (0)