Merge pull request #6284 from tigercl/fix/mongo-health-check

fix(connector): fix crash in health checking of mongo connection
This commit is contained in:
tigercl 2021-11-25 09:23:54 +08:00 committed by GitHub
commit 4a460b3a22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

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