Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Better understanding how to work/balance mnesia's transactional/ACID capabilities

Tags:

erlang

mnesia

I am still trying to deeply understand what one can do with Mnesia, and answers to these two questions would greatly help.

1) What happens if one process does an atomic transaction with respect to Record X while some other process does a dirty transaction involving that same record. Are the first processes' ACID properties compromised?

2) Is there a way for the same process to hold a non-dirty (mnesia:transaction/1) read-lock on one table's row, while simultaneously doing a dirty operation on another table?

like image 767
Jr0 Avatar asked Nov 13 '22 18:11

Jr0


1 Answers

Isolation guarantees are lost in a database environment that allows dirty operations, as Mnesia does. So the answer to question 1) is yes, the well-behaved transactional process is potentially compromised by the concurrent dirty operation, and vice versa - a dirty read for example could return "old" or even freshly deleted data, while the danger inherent in dirty writes is obvious.

In your second scenario, the answer is yes for two reasons: only the data object you're reading is locked AND only your local copy at that! Which is generally a fine and useful thing , and allows even concurrent transactions on other data objects (including other tables of course) to take place.

Erlang Mnesia docs, Chapter 4

like image 132
snwight Avatar answered Nov 15 '22 08:11

snwight