Delete/Create in the same transaction
Ulf Wiger
etxuwig@REDACTED
Tue Apr 17 10:13:35 CEST 2001
On Mon, 16 Apr 2001, Chandrashekhar Mullaparthi wrote:
[snip]
>21> mnesia:transaction(fun() -> mnesia:delete_object({bag, 1, 2}),
>mnesia:write({bag, 1, 2}) end).
>{atomic,ok}
>22>
>22> [mnesia:dirty_read({bag, X}) || X <- mnesia:dirty_all_keys(bag)].
>[[{bag,1,3}]]
>
>In step 21, Why is it that if I delete an object in a transaction
>and write it back again in the same, the object doesn't exist in the
>database?? Intuitively it seems to be a bug....
I don't know if this is your problem, but if you want to verify that
the object actually gets written, you may want to do so with another
transaction. The above test suffers from a race condition in that
dirty operations never wait for a transaction to finish.
The transaction returns when it is committed, but before all the work
is done to make the data visible. Transactions are guaranteed to see
the complete results of earlier transactions but dirty operations are
not.
/Uffe
--
Ulf Wiger tfn: +46 8 719 81 95
Senior System Architect mob: +46 70 519 81 95
Strategic Product & System Management ATM Multiservice Networks
Data Backbone & Optical Services Division Ericsson Telecom AB
More information about the erlang-questions
mailing list