Database / Mnesia intermediate to advanced Interview questions
How do you dynamically add a new node to a running Mnesia cluster?
Bringing a new node into an already-running Mnesia cluster involves connecting it at the Erlang distribution
level first, then explicitly telling Mnesia's schema about it via
mnesia:change_config(extra_db_nodes, [NewNode]), which merges the new node into the existing
schema rather than creating a separate one.
%% on the new node, after connecting to the cluster: mnesia:start(), mnesia:change_config(extra_db_nodes, ['existing_node@host']).
After this, the new node knows about the cluster's existing tables but doesn't automatically hold a copy of
any of them — you still need mnesia:add_table_copy/3 for each table you want it to
replicate. This two-step process (join the schema, then opt into specific tables) is deliberate: it lets a new
node join as, say, a lightweight participant that only replicates a subset of tables relevant to its role.
More Related questions...