@@ -196,23 +196,29 @@ join(RemoteNode, NodeType)
196196 % % RabbitMQ and Mnesia must be stopped to modify the cluster. In
197197 % % particular, we stop Mnesia regardless of the remotely selected
198198 % % database because we might change it during the join.
199- % RestartMnesia = rabbit_mnesia:is_running(),
200- RestartFFCtl = rabbit_ff_controller :is_running (),
201199 RestartRabbit = rabbit :is_running (),
200+ RestartMnesia = rabbit_mnesia :is_running (),
201+ RestartFFCtl = rabbit_ff_controller :is_running (),
202202 case RestartRabbit of
203203 true ->
204204 rabbit :stop ();
205205 false ->
206+ % % When the join happens as part of peer discovery, i.e.
207+ % % when RabbitMQ boots for the first time, `rabbit' is not
208+ % % yet started but the Feature flags controller is already
209+ % % running. We need to stop it to proceed with the reset.
206210 case RestartFFCtl of
207211 true ->
208212 ok = rabbit_ff_controller :wait_for_task_and_stop ();
209213 false ->
210214 ok
211215 end ,
212- % case RestartMnesia of
213- % true -> rabbit_mnesia:stop_mnesia();
214- % false -> ok
215- % end,
216+
217+ % % Likewise with Mnesia during peer discovery.
218+ case RestartMnesia of
219+ true -> rabbit_mnesia :stop_mnesia ();
220+ false -> ok
221+ end ,
216222 ok
217223 end ,
218224
@@ -280,17 +286,21 @@ join(RemoteNode, NodeType)
280286 true ->
281287 rabbit :start ();
282288 false ->
289+ % % If we stopped the Feature flags controller and Mnesia
290+ % % before the reset+join, we need to restart them. Though
291+ % % for Mnesia, we only do it if is is useful (i.e. Khepri
292+ % % is not enabled).
283293 case RestartFFCtl of
284294 true ->
285295 ok = rabbit_sup :start_child (rabbit_ff_controller );
286296 false ->
287297 ok
288298 end ,
289- % NeedMnesia = not rabbit_khepri:is_enabled(),
290- % case RestartMnesia andalso NeedMnesia of
291- % true -> rabbit_mnesia:start_mnesia(false);
292- % false -> ok
293- % end,
299+ NeedMnesia = not rabbit_khepri :is_enabled (),
300+ case RestartMnesia andalso NeedMnesia of
301+ true -> rabbit_mnesia :start_mnesia (false );
302+ false -> ok
303+ end ,
294304 ok
295305 end ,
296306
0 commit comments