Explorar el Código

Merge pull request #11150 from SergeTupchiy/wait-for-emqx_psk_tab

fix(emqx_psk): wait for Mria table on app start
SergeTupchiy hace 2 años
padre
commit
9cf874e37e

+ 1 - 1
apps/emqx_machine/src/emqx_machine.app.src

@@ -3,7 +3,7 @@
     {id, "emqx_machine"},
     {id, "emqx_machine"},
     {description, "The EMQX Machine"},
     {description, "The EMQX Machine"},
     % strict semver, bump manually!
     % strict semver, bump manually!
-    {vsn, "0.2.6"},
+    {vsn, "0.2.7"},
     {modules, []},
     {modules, []},
     {registered, []},
     {registered, []},
     {applications, [kernel, stdlib, emqx_ctl]},
     {applications, [kernel, stdlib, emqx_ctl]},

+ 2 - 1
apps/emqx_machine/src/emqx_machine_boot.erl

@@ -144,7 +144,8 @@ basic_reboot_apps() ->
             emqx_authz,
             emqx_authz,
             emqx_slow_subs,
             emqx_slow_subs,
             emqx_auto_subscribe,
             emqx_auto_subscribe,
-            emqx_plugins
+            emqx_plugins,
+            emqx_psk
         ] ++ basic_reboot_apps_edition(emqx_release:edition()).
         ] ++ basic_reboot_apps_edition(emqx_release:edition()).
 
 
 basic_reboot_apps_edition(ce) ->
 basic_reboot_apps_edition(ce) ->

+ 19 - 0
apps/emqx_psk/include/emqx_psk.hrl

@@ -0,0 +1,19 @@
+%%--------------------------------------------------------------------
+%% Copyright (c) 2023 EMQ Technologies Co., Ltd. All Rights Reserved.
+%%
+%% Licensed under the Apache License, Version 2.0 (the "License");
+%% you may not use this file except in compliance with the License.
+%% You may obtain a copy of the License at
+%%
+%%     http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS,
+%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+%% See the License for the specific language governing permissions and
+%% limitations under the License.
+%%--------------------------------------------------------------------
+
+-define(TAB, emqx_psk).
+
+-define(PSK_SHARD, emqx_psk_shard).

+ 1 - 1
apps/emqx_psk/src/emqx_psk.app.src

@@ -2,7 +2,7 @@
 {application, emqx_psk, [
 {application, emqx_psk, [
     {description, "EMQX PSK"},
     {description, "EMQX PSK"},
     % strict semver, bump manually!
     % strict semver, bump manually!
-    {vsn, "5.0.2"},
+    {vsn, "5.0.3"},
     {modules, []},
     {modules, []},
     {registered, [emqx_psk_sup]},
     {registered, [emqx_psk_sup]},
     {applications, [kernel, stdlib]},
     {applications, [kernel, stdlib]},

+ 1 - 2
apps/emqx_psk/src/emqx_psk.erl

@@ -66,8 +66,7 @@
 
 
 -boot_mnesia({mnesia, [boot]}).
 -boot_mnesia({mnesia, [boot]}).
 
 
--define(TAB, ?MODULE).
--define(PSK_SHARD, emqx_psk_shard).
+-include("emqx_psk.hrl").
 
 
 -define(DEFAULT_DELIMITER, <<":">>).
 -define(DEFAULT_DELIMITER, <<":">>).
 
 

+ 3 - 0
apps/emqx_psk/src/emqx_psk_app.erl

@@ -23,7 +23,10 @@
     stop/1
     stop/1
 ]).
 ]).
 
 
+-include("emqx_psk.hrl").
+
 start(_Type, _Args) ->
 start(_Type, _Args) ->
+    ok = mria:wait_for_tables([?TAB]),
     {ok, Sup} = emqx_psk_sup:start_link(),
     {ok, Sup} = emqx_psk_sup:start_link(),
     {ok, Sup}.
     {ok, Sup}.
 
 

+ 2 - 0
changes/ce/fix-11150.en.md

@@ -0,0 +1,2 @@
+Wait for Mria table when emqx_psk app is being started to ensure that
+PSK data is synced to replicant nodes even if they don't have init PSK file.