@@ -2164,24 +2164,19 @@ leader_health_check(QueueNameOrRegEx, VHost, ProcessLimitThreshold) ->
2164
2164
VHost when is_binary (VHost ) ->
2165
2165
rabbit_amqqueue :list (VHost )
2166
2166
end ,
2167
+ check_process_limit_safety (length (Qs ), ProcessLimitThreshold ),
2167
2168
ParentPID = self (),
2168
2169
HealthCheckRef = make_ref (),
2169
2170
HealthCheckPids =
2170
2171
lists :flatten (
2171
2172
[begin
2172
2173
{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
+ []
2185
2180
end
2186
2181
end || Q <- Qs , amqqueue :get_type (Q ) == ? MODULE ]),
2187
2182
wait_for_leader_health_checks (HealthCheckRef , length (HealthCheckPids ), []).
@@ -2212,5 +2207,11 @@ wait_for_leader_health_checks(Ref, N, UnhealthyAcc) ->
2212
2207
UnhealthyAcc
2213
2208
end .
2214
2209
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