fix(bridge): mqtt bridge worker status idle

This commit is contained in:
JimMoen 2022-08-17 16:03:42 +08:00
parent bffff65df5
commit 768ab4eacd
3 changed files with 22 additions and 7 deletions

View File

@ -1,6 +1,6 @@
{application, emqx_bridge_mqtt,
[{description, "EMQ X Bridge to MQTT Broker"},
{vsn, "4.3.5"}, % strict semver, bump manually!
{vsn, "4.3.6"}, % strict semver, bump manually!
{modules, []},
{registered, []},
{applications, [kernel,stdlib,replayq,emqtt]},

View File

@ -1,7 +1,7 @@
%% -*- mode: erlang -*-
%% Unless you know what you are doing, DO NOT edit manually!!
{VSN,
[{"4.3.4",
[{<<"4\\.3\\.[4-5]">>,
[{load_module,emqx_bridge_mqtt_actions,brutal_purge,soft_purge,[]}]},
{"4.3.3",
[{load_module,emqx_bridge_mqtt_actions,brutal_purge,soft_purge,[]},
@ -14,7 +14,7 @@
{load_module,emqx_bridge_worker,brutal_purge,soft_purge,[]},
{load_module,emqx_bridge_mqtt_actions,brutal_purge,soft_purge,[]}]},
{<<".*">>,[]}],
[{"4.3.4",
[{<<"4\\.3\\.[4-5]">>,
[{load_module,emqx_bridge_mqtt_actions,brutal_purge,soft_purge,[]}]},
{"4.3.3",
[{load_module,emqx_bridge_mqtt_actions,brutal_purge,soft_purge,[]},

View File

@ -433,7 +433,7 @@ test_resource_status(PoolName) ->
try
Status = [
receive {Pid, R} -> R
after 1000 -> %% get_worker_status/1 should be a quick operation
after 10000 -> %% get_worker_status/1 should be a quick operation
throw({timeout, Pid})
end || Pid <- Pids],
lists:any(fun(St) -> St =:= true end, Status)
@ -444,13 +444,28 @@ test_resource_status(PoolName) ->
false
end.
-define(RETRY_TIMES, 4).
get_worker_status(Worker) ->
get_worker_status(Worker, ?RETRY_TIMES).
get_worker_status(_Worker, 0) ->
false;
get_worker_status(Worker, Times) ->
case ecpool_worker:client(Worker) of
{ok, Bridge} ->
try emqx_bridge_worker:status(Bridge) of
connected -> true;
_ -> false
catch _Error:_Reason ->
connected ->
true;
idle ->
?LOG(info, "MQTT Bridge get status idle. Should not ignore this."),
timer:sleep(100),
get_worker_status(Worker, Times - 1);
ErrorStatus ->
?LOG(error, "MQTT Bridge get status ~p", [ErrorStatus]),
false
catch Error:Reason:ST ->
?LOG(error, "MQTT Bridge get status error: ~p reason: ~p stacktrace: ~p", [Error, Reason, ST]),
false
end;
{error, _} ->