@@ -202,11 +202,7 @@ start_cluster(Q) ->
202
202
[QuorumSize , rabbit_misc :rs (QName ), Leader ]),
203
203
case rabbit_amqqueue :internal_declare (NewQ1 , false ) of
204
204
{created , NewQ } ->
205
- TickTimeout = application :get_env (rabbit , quorum_tick_interval ,
206
- ? TICK_TIMEOUT ),
207
- SnapshotInterval = application :get_env (rabbit , quorum_snapshot_interval ,
208
- ? SNAPSHOT_INTERVAL ),
209
- RaConfs = [make_ra_conf (NewQ , ServerId , TickTimeout , SnapshotInterval )
205
+ RaConfs = [make_ra_conf (NewQ , ServerId )
210
206
|| ServerId <- members (NewQ )],
211
207
try erpc_call (Leader , ra , start_cluster ,
212
208
[? RA_SYSTEM , RaConfs , ? START_CLUSTER_TIMEOUT ],
@@ -571,11 +567,10 @@ recover(_Vhost, Queues) ->
571
567
lists :foldl (
572
568
fun (Q0 , {R0 , F0 }) ->
573
569
{Name , _ } = amqqueue :get_pid (Q0 ),
570
+ ServerId = {Name , node ()},
574
571
QName = amqqueue :get_name (Q0 ),
575
- Nodes = get_nodes (Q0 ),
576
- Formatter = {? MODULE , format_ra_event , [QName ]},
577
- Res = case ra :restart_server (? RA_SYSTEM , {Name , node ()},
578
- #{ra_event_formatter => Formatter }) of
572
+ MutConf = make_mutable_config (Q0 ),
573
+ Res = case ra :restart_server (? RA_SYSTEM , ServerId , MutConf ) of
579
574
ok ->
580
575
% queue was restarted, good
581
576
ok ;
@@ -587,10 +582,7 @@ recover(_Vhost, Queues) ->
587
582
[rabbit_misc :rs (QName ), Err1 ]),
588
583
% queue was never started on this node
589
584
% so needs to be started from scratch.
590
- Machine = ra_machine (Q0 ),
591
- RaNodes = [{Name , Node } || Node <- Nodes ],
592
- case ra :start_server (? RA_SYSTEM , Name , {Name , node ()},
593
- Machine , RaNodes ) of
585
+ case start_server (make_ra_conf (Q0 , ServerId )) of
594
586
ok -> ok ;
595
587
Err2 ->
596
588
rabbit_log :warning (" recover: quorum queue ~w could not"
@@ -1105,11 +1097,7 @@ add_member(Q, Node, Timeout) when ?amqqueue_is_quorum(Q) ->
1105
1097
% % TODO parallel calls might crash this, or add a duplicate in quorum_nodes
1106
1098
ServerId = {RaName , Node },
1107
1099
Members = members (Q ),
1108
- TickTimeout = application :get_env (rabbit , quorum_tick_interval ,
1109
- ? TICK_TIMEOUT ),
1110
- SnapshotInterval = application :get_env (rabbit , quorum_snapshot_interval ,
1111
- ? SNAPSHOT_INTERVAL ),
1112
- Conf = make_ra_conf (Q , ServerId , TickTimeout , SnapshotInterval ),
1100
+ Conf = make_ra_conf (Q , ServerId ),
1113
1101
case ra :start_server (? RA_SYSTEM , Conf ) of
1114
1102
ok ->
1115
1103
case ra :add_member (Members , ServerId , Timeout ) of
@@ -1609,6 +1597,13 @@ members(Q) when ?amqqueue_is_quorum(Q) ->
1609
1597
format_ra_event (ServerId , Evt , QRef ) ->
1610
1598
{'$gen_cast' , {queue_event , QRef , {ServerId , Evt }}}.
1611
1599
1600
+ make_ra_conf (Q , ServerId ) ->
1601
+ TickTimeout = application :get_env (rabbit , quorum_tick_interval ,
1602
+ ? TICK_TIMEOUT ),
1603
+ SnapshotInterval = application :get_env (rabbit , quorum_snapshot_interval ,
1604
+ ? SNAPSHOT_INTERVAL ),
1605
+ make_ra_conf (Q , ServerId , TickTimeout , SnapshotInterval ).
1606
+
1612
1607
make_ra_conf (Q , ServerId , TickTimeout , SnapshotInterval ) ->
1613
1608
QName = amqqueue :get_name (Q ),
1614
1609
RaMachine = ra_machine (Q ),
@@ -1628,6 +1623,16 @@ make_ra_conf(Q, ServerId, TickTimeout, SnapshotInterval) ->
1628
1623
machine => RaMachine ,
1629
1624
ra_event_formatter => Formatter }.
1630
1625
1626
+ make_mutable_config (Q ) ->
1627
+ QName = amqqueue :get_name (Q ),
1628
+ TickTimeout = application :get_env (rabbit , quorum_tick_interval ,
1629
+ ? TICK_TIMEOUT ),
1630
+ Formatter = {? MODULE , format_ra_event , [QName ]},
1631
+ #{tick_timeout => TickTimeout ,
1632
+ ra_event_formatter => Formatter }.
1633
+
1634
+
1635
+
1631
1636
get_nodes (Q ) when ? is_amqqueue (Q ) ->
1632
1637
#{nodes := Nodes } = amqqueue :get_type_state (Q ),
1633
1638
Nodes .
0 commit comments