Skip to content

Commit 5a5877a

Browse files
committed
Update nodes entry on make_ra_conf
1 parent d6b9fa0 commit 5a5877a

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

deps/rabbit/src/rabbit_quorum_queue.erl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,20 +1428,20 @@ do_add_member(Q0, Node, Membership, Timeout)
14281428
%% TODO parallel calls might crash this, or add a duplicate in quorum_nodes
14291429
ServerId = {RaName, Node},
14301430
Members = members(Q0),
1431-
QTypeState0 = #{nodes := _Nodes}= amqqueue:get_type_state(Q0),
1431+
QTypeState0 = #{nodes := Nodes} = amqqueue:get_type_state(Q0),
14321432
NewRaUId = ra:new_uid(ra_lib:to_binary(RaName)),
1433-
%QTypeState = case Nodes of
1434-
% L when is_list(L) ->
1435-
% %% Queue is not aware of node to uid mapping, just add the new node
1436-
% QTypeState0#{nodes := lists:usort([Node | Nodes])};
1437-
% #{Node := _} ->
1438-
% %% Queue is aware and uid for targeted node exists, do nothing
1439-
% QTypeState0;
1440-
% _ ->
1441-
% %% Queue is aware but current node has no UId, regen uid
1442-
% QTypeState0#{nodes := Nodes#{Node => NewRaUId}}
1443-
%end,
1444-
Q = amqqueue:set_type_state(Q0, QTypeState0),
1433+
QTypeState = case Nodes of
1434+
L when is_list(L) ->
1435+
%% Queue is not aware of node to uid mapping, just add the new node
1436+
QTypeState0#{nodes => lists:usort([Node | Nodes])};
1437+
#{Node := _} ->
1438+
%% Queue is aware and uid for targeted node exists, do nothing
1439+
QTypeState0;
1440+
_ ->
1441+
%% Queue is aware but current node has no UId, regen uid
1442+
QTypeState0#{nodes => Nodes#{Node => NewRaUId}}
1443+
end,
1444+
Q = amqqueue:set_type_state(Q0, QTypeState),
14451445
MachineVersion = erpc_call(Node, rabbit_fifo, version, [], infinity),
14461446
Conf = make_ra_conf(Q, ServerId, Membership, MachineVersion),
14471447
case ra:start_server(?RA_SYSTEM, Conf) of
@@ -1459,7 +1459,7 @@ do_add_member(Q0, Node, Membership, Timeout)
14591459
Q2 = update_type_state(
14601460
Q1, fun(#{nodes := NodesList} = Ts) when is_list(NodesList) ->
14611461
Ts#{nodes => lists:usort([Node | NodesList])};
1462-
(#{nodes := #{Node := _} = _NodesMap} = Ts) ->
1462+
(#{nodes := #{Node := _}} = Ts) ->
14631463
Ts;
14641464
(#{nodes := NodesMap} = Ts) when is_map(NodesMap) ->
14651465
Ts#{nodes => maps:put(Node, NewRaUId, NodesMap)}
@@ -2047,7 +2047,7 @@ make_ra_conf(Q, ServerId, TickTimeout,
20472047
[{ClusterName, _} | _] = Members = members(Q),
20482048
{_, Node} = ServerId,
20492049
UId = case amqqueue:get_type_state(Q) of
2050-
#{uids := #{Node := Id}} ->
2050+
#{nodes := #{Node := Id}} ->
20512051
Id;
20522052
_ ->
20532053
%% Queue was declared on an older version of RabbitMQ

0 commit comments

Comments
 (0)