Code:
mnesia:create_table(local_config,
[{ram_copies, [node()]},
{local_content, true},
{attributes, record_info(fields, local_config)}]),
mnesia:add_table_copy(local_config, node(), ram_copies),
What's the purpose of this add_table_copy
?
I found ejabberd_config
read configuration later with ETS api directly. Is it relevant with this redundant copy ?
ejabberd is meant to run as a cluster. If this is the first node in the cluster to execute this code, then the table will be created. If this is not the first node, then the table is already created, but we want to make a local copy of the table on this node.
One of the two statements will essentially be a no-op, depending on when the nodes of the cluster execute.