@@ -257,16 +257,27 @@ apply_defs(Map, ActingUser, SuccessFun) when is_function(SuccessFun) ->
257257 concurrent_for_all (permissions , ActingUser , Map , fun add_permission /2 ),
258258 concurrent_for_all (topic_permissions , ActingUser , Map , fun add_topic_permission /2 ),
259259
260- concurrent_for_all (queues , ActingUser , Map , fun add_queue /2 ),
261260 concurrent_for_all (exchanges , ActingUser , Map , fun add_exchange /2 ),
262- concurrent_for_all (bindings , ActingUser , Map , fun add_binding /2 ),
263261
264262 sequential_for_all (global_parameters , ActingUser , Map , fun add_global_parameter /2 ),
265263 % % importing policies concurrently can be unsafe as queues will be getting
266264 % % potentially out of order notifications of applicable policy changes
267265 sequential_for_all (policies , ActingUser , Map , fun add_policy /2 ),
268266 sequential_for_all (parameters , ActingUser , Map , fun add_parameter /2 ),
269267
268+ rabbit_nodes :if_reached_target_cluster_size (
269+ fun () ->
270+ concurrent_for_all (queues , ActingUser , Map , fun add_queue /2 ),
271+ concurrent_for_all (bindings , ActingUser , Map , fun add_binding /2 )
272+ end ,
273+
274+ fun () ->
275+ rabbit_log :info (" There are fewer than target cluster size (~b ) nodes online,"
276+ " skipping queue and binding import from definitions" ,
277+ [rabbit_nodes :target_cluster_size_hint ()])
278+ end
279+ ),
280+
270281 SuccessFun (),
271282 ok
272283 catch {error , E } -> {error , E };
@@ -284,15 +295,25 @@ apply_defs(Map, ActingUser, SuccessFun, VHost) when is_binary(VHost) ->
284295 try
285296 validate_limits (Map , VHost ),
286297
287- concurrent_for_all (queues , ActingUser , Map , VHost , fun add_queue /3 ),
288298 concurrent_for_all (exchanges , ActingUser , Map , VHost , fun add_exchange /3 ),
289- concurrent_for_all (bindings , ActingUser , Map , VHost , fun add_binding /3 ),
290-
291299 sequential_for_all (parameters , ActingUser , Map , VHost , fun add_parameter /3 ),
292300 % % importing policies concurrently can be unsafe as queues will be getting
293301 % % potentially out of order notifications of applicable policy changes
294302 sequential_for_all (policies , ActingUser , Map , VHost , fun add_policy /3 ),
295303
304+ rabbit_nodes :if_reached_target_cluster_size (
305+ fun () ->
306+ concurrent_for_all (queues , ActingUser , Map , VHost , fun add_queue /3 ),
307+ concurrent_for_all (bindings , ActingUser , Map , VHost , fun add_binding /3 )
308+ end ,
309+
310+ fun () ->
311+ rabbit_log :info (" There are fewer than target cluster size (~b ) nodes online,"
312+ " skipping queue and binding import from definitions" ,
313+ [rabbit_nodes :target_cluster_size_hint ()])
314+ end
315+ ),
316+
296317 SuccessFun ()
297318 catch {error , E } -> {error , format (E )};
298319 exit :E -> {error , format (E )}
@@ -310,15 +331,25 @@ apply_defs(Map, ActingUser, SuccessFun, ErrorFun, VHost) ->
310331 try
311332 validate_limits (Map , VHost ),
312333
313- concurrent_for_all (queues , ActingUser , Map , VHost , fun add_queue /3 ),
314- concurrent_for_all (exchanges , ActingUser , Map , VHost , fun add_exchange /3 ),
315334 concurrent_for_all (bindings , ActingUser , Map , VHost , fun add_binding /3 ),
316-
317335 sequential_for_all (parameters , ActingUser , Map , VHost , fun add_parameter /3 ),
318336 % % importing policies concurrently can be unsafe as queues will be getting
319337 % % potentially out of order notifications of applicable policy changes
320338 sequential_for_all (policies , ActingUser , Map , VHost , fun add_policy /3 ),
321339
340+ rabbit_nodes :if_reached_target_cluster_size (
341+ fun () ->
342+ concurrent_for_all (queues , ActingUser , Map , VHost , fun add_queue /3 ),
343+ concurrent_for_all (bindings , ActingUser , Map , VHost , fun add_binding /3 )
344+ end ,
345+
346+ fun () ->
347+ rabbit_log :info (" There are fewer than target cluster size (~b ) nodes online,"
348+ " skipping queue and binding import from definitions" ,
349+ [rabbit_nodes :target_cluster_size_hint ()])
350+ end
351+ ),
352+
322353 SuccessFun ()
323354 catch {error , E } -> ErrorFun (format (E ));
324355 exit :E -> ErrorFun (format (E ))
0 commit comments