Преглед на файлове

Merge pull request #11352 from lafirest/fix/ds_crash

fix(ds): avoid crashes when starting on Windows
zhongwencool преди 2 години
родител
ревизия
a3a1a0468a
променени са 3 файла, в които са добавени 14 реда и са изтрити 2 реда
  1. 12 1
      apps/emqx_durable_storage/src/emqx_ds_app.erl
  2. 1 1
      apps/emqx_durable_storage/src/emqx_durable_storage.app.src
  3. 1 0
      changes/ce/fix-11352.en.md

+ 12 - 1
apps/emqx_durable_storage/src/emqx_ds_app.erl

@@ -4,6 +4,8 @@
 
 
 -module(emqx_ds_app).
 -module(emqx_ds_app).
 
 
+-dialyzer({nowarn_function, storage/0}).
+
 -export([start/2]).
 -export([start/2]).
 
 
 -include("emqx_ds_int.hrl").
 -include("emqx_ds_int.hrl").
@@ -13,13 +15,22 @@ start(_Type, _Args) ->
     emqx_ds_sup:start_link().
     emqx_ds_sup:start_link().
 
 
 init_mnesia() ->
 init_mnesia() ->
+    %% FIXME: This is a temporary workaround to avoid crashes when starting on Windows
     ok = mria:create_table(
     ok = mria:create_table(
         ?SESSION_TAB,
         ?SESSION_TAB,
         [
         [
             {rlog_shard, ?DS_SHARD},
             {rlog_shard, ?DS_SHARD},
             {type, set},
             {type, set},
-            {storage, rocksdb_copies},
+            {storage, storage()},
             {record_name, session},
             {record_name, session},
             {attributes, record_info(fields, session)}
             {attributes, record_info(fields, session)}
         ]
         ]
     ).
     ).
+
+storage() ->
+    case mria:rocksdb_backend_available() of
+        true ->
+            rocksdb_copies;
+        _ ->
+            disc_copies
+    end.

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

@@ -2,7 +2,7 @@
 {application, emqx_durable_storage, [
 {application, emqx_durable_storage, [
     {description, "Message persistence and subscription replays for EMQX"},
     {description, "Message persistence and subscription replays for EMQX"},
     % strict semver, bump manually!
     % strict semver, bump manually!
-    {vsn, "0.1.1"},
+    {vsn, "0.1.2"},
     {modules, []},
     {modules, []},
     {registered, []},
     {registered, []},
     {applications, [kernel, stdlib, rocksdb, gproc, mria]},
     {applications, [kernel, stdlib, rocksdb, gproc, mria]},

+ 1 - 0
changes/ce/fix-11352.en.md

@@ -0,0 +1 @@
+Fixed this [#11345](https://github.com/emqx/emqx/issues/11345) crash issue when starting on Windows or any other platform without RocksDB support.