madclaws

madclaws

Mnesia not reading from disk on a new docker deployment (mix release)

Hi guys,

We have a phoenix application, deployed with mix releases inside docker.

We are trying to use mnesia (disk_copies) inside docker using volumes.

This is working fine when we deploy a new container and even on restarting the container. We can read/write from mnesia (from disk).

Below is the :mnesia.info output, we can see tables are in disk_copies

---> Active tables <--- 
Elixir.GamestateTimeTrial: with 0        records occupying 305      words of mem
Elixir.GamestateTrickShot: with 0        records occupying 305      words of mem
Elixir.GamestateClassic: with 0        records occupying 305      words of mem
schema         : with 4        records occupying 775      words of mem
===> System info in version "4.19.1", debug level = none <===
opt_disc. Directory "/home/elixir/app/mnesiadb" is used.
use fallback at restart = false
running db nodes   = [deadpool@7e1ae5afa43d]
stopped db nodes   = [] 
master node tables = []
remote             = []
ram_copies         = []
disc_copies        = ['Elixir.GamestateClassic','Elixir.GamestateTimeTrial',
                      'Elixir.GamestateTrickShot',schema]
disc_only_copies   = []
[{deadpool@7e1ae5afa43d,disc_copies}] = [schema,'Elixir.GamestateClassic',
                                         'Elixir.GamestateTrickShot',
                                         'Elixir.GamestateTimeTrial']
5 transactions committed, 0 aborted, 0 restarted, 6 logged to disc
0 held locks, 0 in queue; 0 local transactions, 0 remote
0 transactions waits for other nodes: []
:ok

Now the issue is when we deploy a new container of same image (by stopping the old one), and same volume
mnesia is trying to read from ram_copies instead of disk_copies.

we can see disk_copies list is empty contrary to the previous output

---> Active tables <--- 
schema         : with 4        records occupying 775      words of mem
===> System info in version "4.19.1", debug level = none <===
opt_disc. Directory "/home/elixir/app/mnesiadb" is used.
use fallback at restart = false
running db nodes   = [deadpool@bf64da26fdbd]
stopped db nodes   = [deadpool@7e1ae5afa43d] 
master node tables = []
remote             = ['Elixir.GamestateClassic','Elixir.GamestateTimeTrial',
                      'Elixir.GamestateTrickShot']
ram_copies         = [schema]
disc_copies        = []
disc_only_copies   = []
[] = ['Elixir.GamestateTrickShot','Elixir.GamestateClassic',
      'Elixir.GamestateTimeTrial']
[{deadpool@bf64da26fdbd,ram_copies}] = [schema]
2 transactions committed, 3 aborted, 0 restarted, 0 logged to disc
0 held locks, 0 in queue; 0 local transactions, 0 remote
0 transactions waits for other nodes: []
:ok

We can see here that the old stopped container is mentioned in stopped db nodes = [deadpool@7e1ae5afa43d] .

We tried copy tables to disk on every migrations with Mnesia.change_table_copy_type(GamestateClassic, node(), :disc_copies), but we got Tables doesn’t exist.

So basically on a new deployment of a docker image (ex after we do some changes in codebase) with existing volume, mnesia is not reading from disk_copies but works if we just restarts the container.

Any help is much appreciated.

Marked As Solved

ghostdsb

ghostdsb

This problem occurs because erlang uses the hostname as the node name. But in docker, the hostname changes on every new deployment. We can make the node name the same by adding a hostname to the docker container.

Found the answer here.

Where Next?

Popular in Questions Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
Lily
In templates/appointment/index.html.eex: &lt;%= for appointment &lt;- @appointments do %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= appoi...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New

Other popular topics Top

jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
Qqwy
Update: How to use the Blogs &amp; Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 126479 1222
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement