Merge pull request #12814 from SergeTupchiy/EMQX-12124-fix-msgs-api-client-shutdown

fix(emqx_mgmt): catch OOM shutdown exits properly when calling a conn procces
This commit is contained in:
SergeTupchiy 2024-04-01 16:26:54 +03:00 committed by GitHub
commit dd6f65f7dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 1 deletions

View File

@ -711,5 +711,19 @@ call_conn(ConnMod, Pid, Req) ->
exit:R when R =:= shutdown; R =:= normal ->
{error, shutdown};
exit:{R, _} when R =:= shutdown; R =:= noproc ->
{error, shutdown}
{error, shutdown};
exit:{{shutdown, _OOMInfo}, _Location} ->
{error, shutdown};
exit:timeout ->
?SLOG(
warning,
#{
msg => "call_client_connection_process_timeout",
request => Req,
pid => Pid,
module => ConnMod,
stacktrace => erlang:process_info(Pid, current_stacktrace)
}
),
{error, timeout}
end.

View File

@ -1232,6 +1232,8 @@ list_client_msgs(MsgType, ClientID, QString) ->
code => 'NOT_IMPLEMENTED',
message => <<"API not implemented for persistent sessions">>
}};
{error, Reason} ->
?INTERNAL_ERROR(Reason);
{Msgs, Meta = #{}} when is_list(Msgs) ->
format_msgs_resp(MsgType, Msgs, Meta, QString)
end

View File

@ -0,0 +1,4 @@
Handle several errors in `/clients/{clientid}/mqueue_messages` and `/clients/{clientid}/inflight_messages` APIs:
- Internal timeout, which means that EMQX failed to get the list of Inflight/Mqueue messages within the default timeout of 5 s. This error may occur when the system is under a heavy load. The API will return 500 `{"code":"INTERNAL_ERROR","message":"timeout"}` response and log additional details.
- Client shutdown. The error may occur if the client connection is shutdown during the API call. The API will return 404 `{"code": "CLIENT_SHUTDOWN", "message": "Client connection has been shutdown"}` response in this case.