From 80c1128b7a23f947b027ebca2fb076bd0011e071 Mon Sep 17 00:00:00 2001 From: zhouzb Date: Thu, 23 Dec 2021 11:45:58 +0800 Subject: [PATCH] fix(authz): fix deadlock issues --- apps/emqx_authz/src/emqx_authz_http.erl | 4 ++-- apps/emqx_authz/src/emqx_authz_mongodb.erl | 4 ++-- apps/emqx_authz/src/emqx_authz_mysql.erl | 4 ++-- apps/emqx_authz/src/emqx_authz_postgresql.erl | 4 ++-- apps/emqx_authz/src/emqx_authz_redis.erl | 4 ++-- apps/emqx_authz/src/emqx_authz_utils.erl | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/emqx_authz/src/emqx_authz_http.erl b/apps/emqx_authz/src/emqx_authz_http.erl index c2ee96594..fe48b35d0 100644 --- a/apps/emqx_authz/src/emqx_authz_http.erl +++ b/apps/emqx_authz/src/emqx_authz_http.erl @@ -48,12 +48,12 @@ init(#{url := Url} = Source) -> end. destroy(#{annotations := #{id := Id}}) -> - ok = emqx_resource:remove(Id). + ok = emqx_resource:remove_local(Id). dry_run(Source) -> URIMap = maps:get(url, Source), NSource = maps:put(base_url, maps:remove(query, URIMap), Source), - emqx_resource:create_dry_run(emqx_connector_http, NSource). + emqx_resource:create_dry_run_local(emqx_connector_http, NSource). authorize(Client, PubSub, Topic, #{type := http, diff --git a/apps/emqx_authz/src/emqx_authz_mongodb.erl b/apps/emqx_authz/src/emqx_authz_mongodb.erl index 97fac9627..84ef2f302 100644 --- a/apps/emqx_authz/src/emqx_authz_mongodb.erl +++ b/apps/emqx_authz/src/emqx_authz_mongodb.erl @@ -46,10 +46,10 @@ init(Source) -> end. dry_run(Source) -> - emqx_resource:create_dry_run(emqx_connector_mongo, Source). + emqx_resource:create_dry_run_local(emqx_connector_mongo, Source). destroy(#{annotations := #{id := Id}}) -> - ok = emqx_resource:remove(Id). + ok = emqx_resource:remove_local(Id). authorize(Client, PubSub, Topic, #{collection := Collection, diff --git a/apps/emqx_authz/src/emqx_authz_mysql.erl b/apps/emqx_authz/src/emqx_authz_mysql.erl index a5b14ec1b..181478a76 100644 --- a/apps/emqx_authz/src/emqx_authz_mysql.erl +++ b/apps/emqx_authz/src/emqx_authz_mysql.erl @@ -48,10 +48,10 @@ init(#{query := SQL} = Source) -> end. dry_run(Source) -> - emqx_resource:create_dry_run(emqx_connector_mysql, Source). + emqx_resource:create_dry_run_local(emqx_connector_mysql, Source). destroy(#{annotations := #{id := Id}}) -> - ok = emqx_resource:remove(Id). + ok = emqx_resource:remove_local(Id). authorize(Client, PubSub, Topic, #{annotations := #{id := ResourceID, diff --git a/apps/emqx_authz/src/emqx_authz_postgresql.erl b/apps/emqx_authz/src/emqx_authz_postgresql.erl index f101841c2..4e84fe418 100644 --- a/apps/emqx_authz/src/emqx_authz_postgresql.erl +++ b/apps/emqx_authz/src/emqx_authz_postgresql.erl @@ -48,10 +48,10 @@ init(#{query := SQL} = Source) -> end. destroy(#{annotations := #{id := Id}}) -> - ok = emqx_resource:remove(Id). + ok = emqx_resource:remove_local(Id). dry_run(Source) -> - emqx_resource:create_dry_run(emqx_connector_pgsql, Source). + emqx_resource:create_dry_run_local(emqx_connector_pgsql, Source). parse_query(Sql) -> case re:run(Sql, ?RE_PLACEHOLDER, [global, {capture, all, list}]) of diff --git a/apps/emqx_authz/src/emqx_authz_redis.erl b/apps/emqx_authz/src/emqx_authz_redis.erl index 1f6abe330..8765734cf 100644 --- a/apps/emqx_authz/src/emqx_authz_redis.erl +++ b/apps/emqx_authz/src/emqx_authz_redis.erl @@ -46,10 +46,10 @@ init(Source) -> end. destroy(#{annotations := #{id := Id}}) -> - ok = emqx_resource:remove(Id). + ok = emqx_resource:remove_local(Id). dry_run(Source) -> - emqx_resource:create_dry_run(emqx_connector_redis, Source). + emqx_resource:create_dry_run_local(emqx_connector_redis, Source). authorize(Client, PubSub, Topic, #{cmd := CMD, diff --git a/apps/emqx_authz/src/emqx_authz_utils.erl b/apps/emqx_authz/src/emqx_authz_utils.erl index 78140d118..435388e44 100644 --- a/apps/emqx_authz/src/emqx_authz_utils.erl +++ b/apps/emqx_authz/src/emqx_authz_utils.erl @@ -32,7 +32,7 @@ create_resource(Module, Config) -> ResourceID = make_resource_id(Module), - case emqx_resource:create(ResourceID, Module, Config) of + case emqx_resource:create_local(ResourceID, Module, Config) of {ok, already_created} -> {ok, ResourceID}; {ok, _} -> {ok, ResourceID}; {error, Reason} -> {error, Reason} @@ -40,7 +40,7 @@ create_resource(Module, Config) -> cleanup_resources() -> lists:foreach( - fun emqx_resource:remove/1, + fun emqx_resource:remove_local/1, emqx_resource:list_group_instances(?RESOURCE_GROUP)). make_resource_id(Name) ->