fix(connector): fix crash in health checking of mongo connection

This commit is contained in:
zhouzb 2021-11-24 16:48:35 +08:00
parent 6b1ec4f035
commit 261ca3d625
1 changed files with 7 additions and 2 deletions

View File

@ -169,8 +169,13 @@ health_check(PoolName) ->
case ecpool_worker:client(Worker) of
{ok, Conn} ->
%% we don't care if this returns something or not, we just to test the connection
Res = mongo_api:find_one(Conn, <<"foo">>, {}, #{}),
Res == undefined orelse is_map(Res);
try mongo_api:find_one(Conn, <<"foo">>, {}, #{}) of
undefined -> true;
Res when is_map(Res) -> true;
_ -> false
catch
_Class:_Error -> false
end;
_ -> false
end
end || {_WorkerName, Worker} <- ecpool:workers(PoolName)],