[erlang-questions] Mnesia: dirty operations inside transactions
Tue Feb 22 15:48:01 CET 2011
On Tue, Feb 22, 2011 at 10:29 AM, Magnus Henoch
> Hi all,
> I've stumbled upon an apparent contradiction in the Mnesia user manual.
> Section 4.3, "Dirty operations", says:
> "Even if the following [dirty] functions are executed inside a transaction no
> locks will be acquired."
> But section 4.6, "Nested transactions", says:
> "It is also possible to mix different activity access contexts while nesting,
> but the dirty ones (async_dirty,sync_dirty and ets) will inherit the transaction
> semantics if they are called inside a transaction and thus it will grab locks
> and use two or three phase commit."
> So do the dirty functions grab locks or not?
> Is there a difference between calling dirty_write etc directly on one hand,
Yes, mnesia:dirty_write and friends does never grab locks
> and using mnesia:sync_dirty/1 or mnesia:activity/2 on the other hand?
while mnesia:write and friends can grab locks depending on the activity
context. If the activity is a transaction or if it is enclosed in a transaction
(such as a sync_dirty nested in a transaction) mnesia:write etc will grab
locks. Otherwise they will not grab locks.
More information about the erlang-questions