@jchrist thanks again for your replies and for you patience!
I add my remote_node(laptop) tables using:
:erpc.call(cluster_node, fn ->
:mnesia.system_info(:tables)
|> Enum.map(fn table ->
if table != :schema do
result = :mnesia.add_table_copy(table, current_node, :rocksdb_copies)
end
end)
end)
and yes indeed :mnesia.del_table_copy(:schema, node_to_remove)
is actually working even if the node_to_remove
is down.
I was mislead by the fact that :mnesia.del_table_copy(:any_other_node, node_to_remove)
will fail and result will be: {:aborted, {:badarg, :any_other_node, :unknown}}
and I thought that :mnesia.del_table_copy(:schema, node_to_remove)
will fail too. And regarding that I am unsure how del_table_copy works. I originally thought this can be used for any table, not just for the schema.
Moreover if I just cut the network and use :mnesia.del_table_copy(:schema, node_to_remove)
then put the network back it working just as intended(yay!), but if I kill the node_to_remove
then use :mnesia.del_table_copy(:schema, node_to_remove)
and then try to start the node_to_remove
again, I get this:
[error] Mnesia(:"node2@172.21.0.3"): ** ERROR ** (core dumped to file: '/app/MnesiaCore.node2@172.21.0.3_1685_128021_181853')
** FATAL ** Failed to merge schema: {:aborted, :function_clause}
[notice] Application mnesia exited: :mnesia_app.start(:normal, []) returned an error: normal
[notice] Application runtime_tools exited: :stopped
** (Mix) Could not start application mnesia: :mnesia_app.start(:normal, []) returned an error: normal
And even when I use the cutting network option I cannot figure out what to do after the manual conflict resolution.
My assumptions were that I could do this by using :mnesia.set_master_nodes(table, [remote_node])
(which outputs :ok
but does nothing) from cluster to overwrite remote_node(laptop) and having the sync on again. Or maybe :mnesia.add_table_copy/3
to make them sync again, but it seems the only way is to use :mnesia.delete_schema
on the remote_node and then use add_table_copy
like in the first code paragraph above.
If you know about any additional documentation that could use for my use case please suggest it to me.