[erlang-questions] Mnesia Transaction Race Condition

Vance Shipley vances@REDACTED
Wed Oct 24 16:44:37 CEST 2012


I have two mnesia transactions running on two different nodes
operating on distributed tables.  Some of the time the earlier
transaction is committed at one node later than the first.  I
would have thought this wasn't possible.

The first table is distributed across nodes A & B.
The second table is distributed across nodes C & D.

A process on node A performs a transaction which writes to the
first table and the second table.

A process on node C, which is guaranteed to begin after the first
transaction has finished, deletes the object in the second table.

Perform this 50000 times sequentially and find that the copy of
the second table on node D contains fifty or so objects which
should have been deleted in the transaction on node C.

Tracing with mnesia:set_debug_level/1 reveals that the write from
the first transaction is being applied after the delete_object of
the second transaction:

   Mnesia(d@REDACTED): delete_object performed by {tid, 598430, <3388.4769.15>}
   Mnesia(d@REDACTED): write performed by {tid, 598428, <3455.3722.0>}

What do I have to do to keep the tables consistant?
Why would tid 598430 be applied before tid 598428 on node D?

-- 
	-Vance



More information about the erlang-questions mailing list