@@ -2164,24 +2164,19 @@ leader_health_check(QueueNameOrRegEx, VHost, ProcessLimitThreshold) ->
21642164 VHost when is_binary (VHost ) ->
21652165 rabbit_amqqueue :list (VHost )
21662166 end ,
2167+ check_process_limit_safety (length (Qs ), ProcessLimitThreshold ),
21672168 ParentPID = self (),
21682169 HealthCheckRef = make_ref (),
21692170 HealthCheckPids =
21702171 lists :flatten (
21712172 [begin
21722173 {resource , _VHostN , queue , QueueName } = QResource = amqqueue :get_name (Q ),
2173- case check_process_limit_safety (ProcessLimitThreshold ) of
2174- true ->
2175- case re :run (QueueName , QueueNameOrRegEx , [{capture , none }]) of
2176- match ->
2177- {ClusterName , _ } = rabbit_amqqueue :pid_of (Q ),
2178- _Pid = spawn (fun () -> run_leader_health_check (ClusterName , QResource , HealthCheckRef , ParentPID ) end );
2179- _ ->
2180- []
2181- end ;
2182- false ->
2183- rabbit_log :warning (" Leader health check failed from exceeded process limit threshold" ),
2184- throw ({error , leader_health_check_process_limit_exceeded })
2174+ case re :run (QueueName , QueueNameOrRegEx , [{capture , none }]) of
2175+ match ->
2176+ {ClusterName , _ } = rabbit_amqqueue :pid_of (Q ),
2177+ _Pid = spawn (fun () -> run_leader_health_check (ClusterName , QResource , HealthCheckRef , ParentPID ) end );
2178+ _ ->
2179+ []
21852180 end
21862181 end || Q <- Qs , amqqueue :get_type (Q ) == ? MODULE ]),
21872182 wait_for_leader_health_checks (HealthCheckRef , length (HealthCheckPids ), []).
@@ -2212,5 +2207,11 @@ wait_for_leader_health_checks(Ref, N, UnhealthyAcc) ->
22122207 UnhealthyAcc
22132208 end .
22142209
2215- check_process_limit_safety (ProcessLimitThreshold ) ->
2216- erlang :system_info (process_count ) < ProcessLimitThreshold .
2210+ check_process_limit_safety (QCount , ProcessLimitThreshold ) ->
2211+ case (erlang :system_info (process_count ) + QCount ) >= ProcessLimitThreshold of
2212+ true ->
2213+ rabbit_log :warning (" Leader health check not permitted, process limit threshold will be exceeded." ),
2214+ throw ({error , leader_health_check_process_limit_exceeded });
2215+ false ->
2216+ ok
2217+ end .
0 commit comments