Merge pull request #9850 from zmstone/0127-fix-influxdb-bridge-atom-leak
0127 fix influxdb bridge atom leak
This commit is contained in:
commit
514609bcf7
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
-export([
|
-export([
|
||||||
load/0,
|
load/0,
|
||||||
|
unload/0,
|
||||||
lookup/1,
|
lookup/1,
|
||||||
lookup/2,
|
lookup/2,
|
||||||
lookup/3,
|
lookup/3,
|
||||||
|
@ -75,6 +76,21 @@ load() ->
|
||||||
maps:to_list(Bridges)
|
maps:to_list(Bridges)
|
||||||
).
|
).
|
||||||
|
|
||||||
|
unload() ->
|
||||||
|
unload_hook(),
|
||||||
|
Bridges = emqx:get_config([bridges], #{}),
|
||||||
|
lists:foreach(
|
||||||
|
fun({Type, NamedConf}) ->
|
||||||
|
lists:foreach(
|
||||||
|
fun({Name, _Conf}) ->
|
||||||
|
_ = emqx_bridge_resource:stop(Type, Name)
|
||||||
|
end,
|
||||||
|
maps:to_list(NamedConf)
|
||||||
|
)
|
||||||
|
end,
|
||||||
|
maps:to_list(Bridges)
|
||||||
|
).
|
||||||
|
|
||||||
safe_load_bridge(Type, Name, Conf, Opts) ->
|
safe_load_bridge(Type, Name, Conf, Opts) ->
|
||||||
try
|
try
|
||||||
_Res = emqx_bridge_resource:create(Type, Name, Conf, Opts),
|
_Res = emqx_bridge_resource:create(Type, Name, Conf, Opts),
|
||||||
|
|
|
@ -39,7 +39,7 @@ start(_StartType, _StartArgs) ->
|
||||||
stop(_State) ->
|
stop(_State) ->
|
||||||
emqx_conf:remove_handler(?LEAF_NODE_HDLR_PATH),
|
emqx_conf:remove_handler(?LEAF_NODE_HDLR_PATH),
|
||||||
emqx_conf:remove_handler(?TOP_LELVE_HDLR_PATH),
|
emqx_conf:remove_handler(?TOP_LELVE_HDLR_PATH),
|
||||||
ok = emqx_bridge:unload_hook(),
|
ok = emqx_bridge:unload(),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
-if(?EMQX_RELEASE_EDITION == ee).
|
-if(?EMQX_RELEASE_EDITION == ee).
|
||||||
|
|
|
@ -309,6 +309,7 @@ init({Data, Opts}) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
terminate(_Reason, _State, Data) ->
|
terminate(_Reason, _State, Data) ->
|
||||||
|
_ = stop_resource(Data),
|
||||||
_ = maybe_clear_alarm(Data#data.id),
|
_ = maybe_clear_alarm(Data#data.id),
|
||||||
delete_cache(Data#data.id, Data#data.manager_id),
|
delete_cache(Data#data.id, Data#data.manager_id),
|
||||||
ok.
|
ok.
|
||||||
|
@ -334,8 +335,7 @@ handle_event({call, From}, start, _State, _Data) ->
|
||||||
% Called when the resource received a `quit` message
|
% Called when the resource received a `quit` message
|
||||||
handle_event(info, quit, stopped, _Data) ->
|
handle_event(info, quit, stopped, _Data) ->
|
||||||
{stop, {shutdown, quit}};
|
{stop, {shutdown, quit}};
|
||||||
handle_event(info, quit, _State, Data) ->
|
handle_event(info, quit, _State, _Data) ->
|
||||||
_ = stop_resource(Data),
|
|
||||||
{stop, {shutdown, quit}};
|
{stop, {shutdown, quit}};
|
||||||
% Called when the resource is to be stopped
|
% Called when the resource is to be stopped
|
||||||
handle_event({call, From}, stop, stopped, _Data) ->
|
handle_event({call, From}, stop, stopped, _Data) ->
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{erl_opts, [debug_info]}.
|
{erl_opts, [debug_info]}.
|
||||||
{deps, [
|
{deps, [
|
||||||
{hstreamdb_erl, {git, "https://github.com/hstreamdb/hstreamdb_erl.git", {tag, "0.2.5"}}},
|
{hstreamdb_erl, {git, "https://github.com/hstreamdb/hstreamdb_erl.git", {tag, "0.2.5"}}},
|
||||||
{influxdb, {git, "https://github.com/emqx/influxdb-client-erl", {tag, "1.1.7"}}},
|
{influxdb, {git, "https://github.com/emqx/influxdb-client-erl", {tag, "1.1.8"}}},
|
||||||
{emqx, {path, "../../apps/emqx"}}
|
{emqx, {path, "../../apps/emqx"}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
|
|
@ -282,7 +282,7 @@ client_config(
|
||||||
{host, str(Host)},
|
{host, str(Host)},
|
||||||
{port, Port},
|
{port, Port},
|
||||||
{pool_size, erlang:system_info(schedulers)},
|
{pool_size, erlang:system_info(schedulers)},
|
||||||
{pool, binary_to_atom(InstId, utf8)},
|
{pool, InstId},
|
||||||
{precision, atom_to_binary(maps:get(precision, Config, ms), utf8)}
|
{precision, atom_to_binary(maps:get(precision, Config, ms), utf8)}
|
||||||
] ++ protocol_config(Config).
|
] ++ protocol_config(Config).
|
||||||
|
|
||||||
|
|
4
mix.exs
4
mix.exs
|
@ -47,7 +47,7 @@ defmodule EMQXUmbrella.MixProject do
|
||||||
{:lc, github: "emqx/lc", tag: "0.3.2", override: true},
|
{:lc, github: "emqx/lc", tag: "0.3.2", override: true},
|
||||||
{:redbug, "2.0.8"},
|
{:redbug, "2.0.8"},
|
||||||
{:typerefl, github: "ieQu1/typerefl", tag: "0.9.1", override: true},
|
{:typerefl, github: "ieQu1/typerefl", tag: "0.9.1", override: true},
|
||||||
{:ehttpc, github: "emqx/ehttpc", tag: "0.4.4", override: true},
|
{:ehttpc, github: "emqx/ehttpc", tag: "0.4.5", override: true},
|
||||||
{:gproc, github: "uwiger/gproc", tag: "0.8.0", override: true},
|
{:gproc, github: "uwiger/gproc", tag: "0.8.0", override: true},
|
||||||
{:jiffy, github: "emqx/jiffy", tag: "1.0.5", override: true},
|
{:jiffy, github: "emqx/jiffy", tag: "1.0.5", override: true},
|
||||||
{:cowboy, github: "emqx/cowboy", tag: "2.9.0", override: true},
|
{:cowboy, github: "emqx/cowboy", tag: "2.9.0", override: true},
|
||||||
|
@ -57,7 +57,7 @@ defmodule EMQXUmbrella.MixProject do
|
||||||
{:gen_rpc, github: "emqx/gen_rpc", tag: "2.8.1", override: true},
|
{:gen_rpc, github: "emqx/gen_rpc", tag: "2.8.1", override: true},
|
||||||
{:grpc, github: "emqx/grpc-erl", tag: "0.6.7", override: true},
|
{:grpc, github: "emqx/grpc-erl", tag: "0.6.7", override: true},
|
||||||
{:minirest, github: "emqx/minirest", tag: "1.3.7", override: true},
|
{:minirest, github: "emqx/minirest", tag: "1.3.7", override: true},
|
||||||
{:ecpool, github: "emqx/ecpool", tag: "0.5.2", override: true},
|
{:ecpool, github: "emqx/ecpool", tag: "0.5.3", override: true},
|
||||||
{:replayq, github: "emqx/replayq", tag: "0.3.6", override: true},
|
{:replayq, github: "emqx/replayq", tag: "0.3.6", override: true},
|
||||||
{:pbkdf2, github: "emqx/erlang-pbkdf2", tag: "2.0.4", override: true},
|
{:pbkdf2, github: "emqx/erlang-pbkdf2", tag: "2.0.4", override: true},
|
||||||
{:emqtt, github: "emqx/emqtt", tag: "1.7.0-rc.2", override: true},
|
{:emqtt, github: "emqx/emqtt", tag: "1.7.0-rc.2", override: true},
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
, {gpb, "4.19.5"} %% gpb only used to build, but not for release, pin it here to avoid fetching a wrong version due to rebar plugins scattered in all the deps
|
, {gpb, "4.19.5"} %% gpb only used to build, but not for release, pin it here to avoid fetching a wrong version due to rebar plugins scattered in all the deps
|
||||||
, {typerefl, {git, "https://github.com/ieQu1/typerefl", {tag, "0.9.1"}}}
|
, {typerefl, {git, "https://github.com/ieQu1/typerefl", {tag, "0.9.1"}}}
|
||||||
, {gun, {git, "https://github.com/emqx/gun", {tag, "1.3.9"}}}
|
, {gun, {git, "https://github.com/emqx/gun", {tag, "1.3.9"}}}
|
||||||
, {ehttpc, {git, "https://github.com/emqx/ehttpc", {tag, "0.4.4"}}}
|
, {ehttpc, {git, "https://github.com/emqx/ehttpc", {tag, "0.4.5"}}}
|
||||||
, {gproc, {git, "https://github.com/uwiger/gproc", {tag, "0.8.0"}}}
|
, {gproc, {git, "https://github.com/uwiger/gproc", {tag, "0.8.0"}}}
|
||||||
, {jiffy, {git, "https://github.com/emqx/jiffy", {tag, "1.0.5"}}}
|
, {jiffy, {git, "https://github.com/emqx/jiffy", {tag, "1.0.5"}}}
|
||||||
, {cowboy, {git, "https://github.com/emqx/cowboy", {tag, "2.9.0"}}}
|
, {cowboy, {git, "https://github.com/emqx/cowboy", {tag, "2.9.0"}}}
|
||||||
|
@ -59,7 +59,7 @@
|
||||||
, {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.8.1"}}}
|
, {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.8.1"}}}
|
||||||
, {grpc, {git, "https://github.com/emqx/grpc-erl", {tag, "0.6.7"}}}
|
, {grpc, {git, "https://github.com/emqx/grpc-erl", {tag, "0.6.7"}}}
|
||||||
, {minirest, {git, "https://github.com/emqx/minirest", {tag, "1.3.7"}}}
|
, {minirest, {git, "https://github.com/emqx/minirest", {tag, "1.3.7"}}}
|
||||||
, {ecpool, {git, "https://github.com/emqx/ecpool", {tag, "0.5.2"}}}
|
, {ecpool, {git, "https://github.com/emqx/ecpool", {tag, "0.5.3"}}}
|
||||||
, {replayq, {git, "https://github.com/emqx/replayq.git", {tag, "0.3.6"}}}
|
, {replayq, {git, "https://github.com/emqx/replayq.git", {tag, "0.3.6"}}}
|
||||||
, {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {tag, "2.0.4"}}}
|
, {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {tag, "2.0.4"}}}
|
||||||
, {emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.7.0-rc.2"}}}
|
, {emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.7.0-rc.2"}}}
|
||||||
|
|
Loading…
Reference in New Issue