[erlang-questions] Some mnesia oddity

Dan Gudmundsson <>
Fri Aug 29 13:20:07 CEST 2008



Chandru wrote:
> 
> 2008/8/29 Nicolas Thauvin < 
> <mailto:>>
> 
>     Hi folks,
> 
>      We found a strange mnesia behavior here...
> 
>     Some mnesia:write operations after a mnesia:delete_object seem to
>     not have the expected result when executed in the same transaction.
> 
>     See attached example file:
>     1 - We fill a test_table
>     2 - In the same transaction, we read all records, delete them, and
>     write them back (do not ask why :))
>     3 - Surprise! Only a subset of them can be read afterwards
> 
>     Same result in R11 and R12.
> 
>     It works if the delete_object and write operations are in separate
>     transactions... But who knows what can happen between them...
> 
> 
> According to the mnesia documentation, I don't think this is a valid 
> invocation of mnesia:delete_object/1 (though why it sort of works is a 
> mystery).
I was just checking it out and came to the same conclusion.
It is not valid, but I agree about the mystery..will fix as soon as possible.

Thanks
/Dan
> 
> The following change to the fun makes it behave as you expect it to.
> 
> 32c32,34
> <                 ok = mnesia:delete_object(Wild_pattern),
> ---
>  >               lists:foreach(fun(X) ->
>  >                                     ok = mnesia:delete_object(X)
>  >                             end, Records),
> 
> cheers
> Chandru
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions



More information about the erlang-questions mailing list