Search code examples
erlangmnesia

How to reconnect a crashed erlang mnesia node to cluster again?


I'm learning erlang and mnesia. I have a question: how to reconncet a "crashed" erlang mnesia node to cluster again?

Erlang/OTP 17 [erts-6.2]

What I did:

  1. Two mnesia nodes: m11@deb83-11 and m12@deb83-12. They were connected with each other well.

    (m11@deb83-11)4> mnesia:system_info(running_db_nodes).
    ['m12@deb83-12','m11@deb83-11']
    
  2. Then I teminated the erl shell of m12@deb83-12 by "Ctl-G" and "q" without stopping mnesia.

  3. After that, I restarted erl shell for m12@deb83-12 node with same command line.

  4. I found the restarted node m12@deb83-12 did not connect to m11@deb83-11.

    (m11@deb83-11)16> mnesia:system_info(running_db_nodes).
    ['m11@deb83-11']
    

Note 1. If i stopped mnesia in step#2, m12@deb83-12 would reconnect to m11@deb83-11 successfully after step#3)

Note 2. I did not create any table. There is only an empty schema in this cluster.

Thanks in advance!

Ming


Solution

  • Apparently all you need to do is connect to the other node (so that nodes(). returns the other node) and restart mnesia with mnesia:stop(). and mnesia:start()..