@@ -239,11 +239,7 @@ start_cluster(Q) ->
239
239
[QuorumSize , rabbit_misc :rs (QName ), Leader ]),
240
240
case rabbit_amqqueue :internal_declare (NewQ1 , false ) of
241
241
{created , NewQ } ->
242
- TickTimeout = application :get_env (rabbit , quorum_tick_interval ,
243
- ? TICK_TIMEOUT ),
244
- SnapshotInterval = application :get_env (rabbit , quorum_snapshot_interval ,
245
- ? SNAPSHOT_INTERVAL ),
246
- RaConfs = [make_ra_conf (NewQ , ServerId , TickTimeout , SnapshotInterval )
242
+ RaConfs = [make_ra_conf (NewQ , ServerId )
247
243
|| ServerId <- members (NewQ )],
248
244
try erpc_call (Leader , ra , start_cluster ,
249
245
[? RA_SYSTEM , RaConfs , ? START_CLUSTER_TIMEOUT ],
@@ -625,11 +621,10 @@ recover(_Vhost, Queues) ->
625
621
lists :foldl (
626
622
fun (Q0 , {R0 , F0 }) ->
627
623
{Name , _ } = amqqueue :get_pid (Q0 ),
624
+ ServerId = {Name , node ()},
628
625
QName = amqqueue :get_name (Q0 ),
629
- Nodes = get_nodes (Q0 ),
630
- Formatter = {? MODULE , format_ra_event , [QName ]},
631
- Res = case ra :restart_server (? RA_SYSTEM , {Name , node ()},
632
- #{ra_event_formatter => Formatter }) of
626
+ MutConf = make_mutable_config (Q0 ),
627
+ Res = case ra :restart_server (? RA_SYSTEM , ServerId , MutConf ) of
633
628
ok ->
634
629
% queue was restarted, good
635
630
ok ;
@@ -641,10 +636,7 @@ recover(_Vhost, Queues) ->
641
636
[rabbit_misc :rs (QName ), Err1 ]),
642
637
% queue was never started on this node
643
638
% so needs to be started from scratch.
644
- Machine = ra_machine (Q0 ),
645
- RaNodes = [{Name , Node } || Node <- Nodes ],
646
- case ra :start_server (? RA_SYSTEM , Name , {Name , node ()},
647
- Machine , RaNodes ) of
639
+ case start_server (make_ra_conf (Q0 , ServerId )) of
648
640
ok -> ok ;
649
641
Err2 ->
650
642
rabbit_log :warning (" recover: quorum queue ~w could not"
@@ -1195,11 +1187,7 @@ add_member(Q, Node, Membership, Timeout) when ?amqqueue_is_quorum(Q) ->
1195
1187
% % TODO parallel calls might crash this, or add a duplicate in quorum_nodes
1196
1188
ServerId = {RaName , Node },
1197
1189
Members = members (Q ),
1198
- TickTimeout = application :get_env (rabbit , quorum_tick_interval ,
1199
- ? TICK_TIMEOUT ),
1200
- SnapshotInterval = application :get_env (rabbit , quorum_snapshot_interval ,
1201
- ? SNAPSHOT_INTERVAL ),
1202
- Conf = make_ra_conf (Q , ServerId , TickTimeout , SnapshotInterval , Membership ),
1190
+ Conf = make_ra_conf (Q , ServerId , Membership ),
1203
1191
case ra :start_server (? RA_SYSTEM , Conf ) of
1204
1192
ok ->
1205
1193
ServerIdSpec = maps :with ([id , uid , membership ], Conf ),
@@ -1742,8 +1730,15 @@ members(Q) when ?amqqueue_is_quorum(Q) ->
1742
1730
format_ra_event (ServerId , Evt , QRef ) ->
1743
1731
{'$gen_cast' , {queue_event , QRef , {ServerId , Evt }}}.
1744
1732
1745
- make_ra_conf (Q , ServerId , TickTimeout , SnapshotInterval ) ->
1746
- make_ra_conf (Q , ServerId , TickTimeout , SnapshotInterval , voter ).
1733
+ make_ra_conf (Q , ServerId ) ->
1734
+ make_ra_conf (Q , ServerId , voter ).
1735
+
1736
+ make_ra_conf (Q , ServerId , Membership ) ->
1737
+ TickTimeout = application :get_env (rabbit , quorum_tick_interval ,
1738
+ ? TICK_TIMEOUT ),
1739
+ SnapshotInterval = application :get_env (rabbit , quorum_snapshot_interval ,
1740
+ ? SNAPSHOT_INTERVAL ),
1741
+ make_ra_conf (Q , ServerId , TickTimeout , SnapshotInterval , Membership ).
1747
1742
1748
1743
make_ra_conf (Q , ServerId , TickTimeout , SnapshotInterval , Membership ) ->
1749
1744
QName = amqqueue :get_name (Q ),
@@ -1765,6 +1760,16 @@ make_ra_conf(Q, ServerId, TickTimeout, SnapshotInterval, Membership) ->
1765
1760
machine => RaMachine ,
1766
1761
ra_event_formatter => Formatter }).
1767
1762
1763
+ make_mutable_config (Q ) ->
1764
+ QName = amqqueue :get_name (Q ),
1765
+ TickTimeout = application :get_env (rabbit , quorum_tick_interval ,
1766
+ ? TICK_TIMEOUT ),
1767
+ Formatter = {? MODULE , format_ra_event , [QName ]},
1768
+ #{tick_timeout => TickTimeout ,
1769
+ ra_event_formatter => Formatter }.
1770
+
1771
+
1772
+
1768
1773
get_nodes (Q ) when ? is_amqqueue (Q ) ->
1769
1774
#{nodes := Nodes } = amqqueue :get_type_state (Q ),
1770
1775
Nodes .
0 commit comments