Hello, everyone
I’m trying to create a Mnesia table with using the mnesiam
package, but can’t understand what the issue is happening during creation.
The table is very simple and doesn’t contain something special:
defmodule Matchmaking.Model.LobbyState do
alias :mnesia, as: Mnesia
@table Matchmaking.Model.LobbyState
@attributes [
:id, # UUID
:dump # Shared state in JSON as string
]
def init_store() do
Mnesia.create_table(
@table,
[
type: :set,
disc_copies: [Node.self()],
record_name: @table,
attributes: @attributes
]
)
end
def copy_store() do
Mnesia.add_table_copy(@table, Node.self(), :disc_copies)
end
end
If I’m trying to call the init_store/0
manually, then it returns the following record:
iex(1)> Matchmaking.Model.LobbyState.init_store()
{aborted: {:bad_type, Matchmaking.Model.LobbyState, :disc_copies, :nonode@nohost}
and :mnesia.system_info
returns this:
iex(2)> :mnesia.system_info
===> System info in version "4.15.3", debug level = none <===
opt_disc. Directory "/app/mnesia_disc_dump" is NOT used.
use fallback at restart = false
running db nodes = [nonode@nohost]
stopped db nodes = []
master node tables = []
remote = []
ram_copies = ['Elixir.Matchmaking.Model.ActiveUser',schema]
disc_copies = []
disc_only_copies = []
[{nonode@nohost,ram_copies}] = [schema,'Elixir.Matchmaking.Model.ActiveUser']
3 transactions committed, 7 aborted, 0 restarted, 0 logged to disc
0 held locks, 0 in queue; 0 local transactions, 0 remote
0 transactions waits for other nodes: []
:yes
Finding the answer to this issue led to the adding a variable in configs (for using disc_copies
tables you will need to define a directory for storing dumps). However, an attempt to specify a directory in config.exc
:
config :mnesia, :dir, System.get_env("MNESIA_DUMP_DIRECTORY") || '/app/mnesia_disc_dump'
with rights for writing/reading/executing didn’t help me. The expected table still isn’t created and returns the same error as was recently mentioned.
Anybody had faced with the same issue before? How it can be solved?