[erlang-questions] Mnesia Transactions
Mon Nov 22 17:28:37 CET 2010
On Mon, Nov 22, 2010 at 4:47 PM, Evans, Matthew <> wrote:
> Hi Team,
> I have a quick question WRT mnesia and transactions, and can't seem to find the answer anywhere.
> Let us say I have a distributed table that is active on several nodes, and wish to apply a transaction to insert multiple records in that table. Is each operation inside that transaction applied individually on each node, or is the whole transaction applied on each node in turn?
> For example
> ListOfOneThousandRecords = create_records(),
> mnesia:transaction(fun() ->
> So this transaction will insert 1000 records into the table.
> Will mnesia:
> 1) Take the record in turn and insert it into node1, node2...node X , take
> the second record and insert into node1, node2...node X until complete.
> 2) Apply the whole transaction to node1 (insert all 1000 records locally)
> and then apply the fun (again locally) to node 2 and so on?
3) Mnesia sends all records(*) to the involved nodes so they can perform their
commit work in parallel. Depending on the type of transaction, Mnesia will then
either wait for the local node to commit (transaction) or all nodes to commit
(sync_transaction) before the function returns.
*) If several tables are involved in the transaction, different sets
of records may be
sent to different nodes.
More information about the erlang-questions