derek-zhou:
However, it can be easier to reproduce by running it in a loop with kill -9
and checking for data in the application level. If you can reproduce the failure I am sure other people on this forum can offer more help, such as to add instrumentation, code change, etc, to pin point the problem.
If I understand you correctly I just need to write a script that keeps writing and reading from Mnesia in an infinite loop and then I kill it with kill -9
?
If yes, then my application was not in active use when I lost the data, by other words it was running but I was not using it.
Anyway I can try it, maybe using a script like the one used to show the issue with the Mnesia durability guarantees?
I’m observing behavior with mnesia that is unexpected by me and could use some help understanding what’s going on. I’ve tested this with erlang 21.0.1 and 21.2.2, and elixir 1.7.4.
Given two scripts:
write.exs
IO.puts "Creating schema..."
:ok = :mnesia.create_schema([node()])
IO.puts "Starting mnesia..."
:ok = :mnesia.start()
IO.puts "Creating table..."
{:atomic, :ok} = :mnesia.create_table(:example, [{:disc_only_copies, [node()]}, type: :set, attributes: [:name, :value]])
IO.puts "Setting :f…
Given two scripts:
write.exs
IO.puts "Creating schema..."
:ok = :mnesia.create_schema([node()])
IO.puts "Starting mnesia..."
:ok = :mnesia.start()
IO.puts "Creating table..."
{:atomic, :ok} = :mnesia.create_table(:example, [{:disc_only_copies, [node()]}, type: :set, attributes: [:name, :value]])
IO.puts "Setting :foo = 1..."
{:atomic, :ok} = :mnesia.transaction(fn -> :mnesia.write({:example, :foo, 1}) end)
IO.puts "Looking up :foo..."
:mnesia.transaction(fn -> :mnesia.read({:example, :foo}) end) |> IO.inspect
IO.puts "Done."
read.exs
IO.puts "Starting mnesia..."
:ok = :mnesia.start()
IO.puts "Waiting until table is loaded..."
:mnesia.wait_for_tables([:example], 1_000)
IO.puts "Looking up :foo..."
:mnesia.transaction(fn -> :mnesia.read({:example, :foo}) end) |> IO.inspect
IO.puts "Done."
When I run these scripts:
rm -rf Mnesia.nonode@nohost; mix run write.exs; mix run read.exs
Or are you thinking that instead I should just use my app:
start my app as usual with mix phx.server
.
use it from the browser as usual
leave it running for a while
Kill it with kill -9