Merge pull request #7419 from EMQ-YangM/fix_health_check_crash

fix(emqx_resource_instance): improve the pattern match of the call_health_check
This commit is contained in:
Xinyu Liu 2022-03-25 18:42:22 +08:00 committed by GitHub
commit 0f4f6b4fb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -265,7 +265,7 @@ call_start(InstId, Mod, Config) ->
?SAFE_CALL(Mod:on_start(InstId, Config)). ?SAFE_CALL(Mod:on_start(InstId, Config)).
-spec call_health_check(instance_id(), module(), resource_state()) -> -spec call_health_check(instance_id(), module(), resource_state()) ->
{ok, resource_state()} | {error, Reason:: term(), resource_state()}. {ok, resource_state()} | {error, Reason:: term()} | {error, Reason:: term(), resource_state()}.
call_health_check(InstId, Mod, ResourceState) -> call_health_check(InstId, Mod, ResourceState) ->
?SAFE_CALL(Mod:on_health_check(InstId, ResourceState)). ?SAFE_CALL(Mod:on_health_check(InstId, ResourceState)).

View File

@ -295,6 +295,11 @@ do_health_check(Group, #{id := InstId, mod := Mod, state := ResourceState0} = Da
ets:insert(emqx_resource_instance, ets:insert(emqx_resource_instance,
{InstId, Group, Data#{status => connected, state => ResourceState1}}), {InstId, Group, Data#{status => connected, state => ResourceState1}}),
ok; ok;
{error, Reason} ->
logger:error("health check for ~p failed: ~p", [InstId, Reason]),
ets:insert(emqx_resource_instance,
{InstId, Group, Data#{status => connecting}}),
{error, Reason};
{error, Reason, ResourceState1} -> {error, Reason, ResourceState1} ->
logger:error("health check for ~p failed: ~p", [InstId, Reason]), logger:error("health check for ~p failed: ~p", [InstId, Reason]),
ets:insert(emqx_resource_instance, ets:insert(emqx_resource_instance,