[erlang-bugs] mnesia:dirty_update_counter doesn't work as expected in mnesia_frag context

Aleksander Nycz Aleksander.Nycz@REDACTED
Fri Jul 10 16:10:06 CEST 2015


Hello,

Please create frag table:

rd(testCounter, {key, value}).
testCounter

mnesia:create_table(tTest
                        , [{ram_copies, [node()]}
                          ,{type,set}
                          ,{attributes,record_info(fields, testCounter)}
                          ,{record_name, testCounter}
                          ,{frag_properties, [{n_fragments, 10}, 
{n_ram_copies, 1}, {node_pool, [node()]}]}])

and insert record using mnesia:write/3 func, that is called in 
mnesia_frag  access context:

mnesia:activity(sync_dirty, fun()-> mnesia:table_info(tTest, size) end, 
[], mnesia_frag).
0
mnesia:activity(sync_dirty, fun() -> mnesia:write(tTest, {testCounter, 
100, 200}, write) end, [], mnesia_frag).
ok
mnesia:activity(sync_dirty, fun()-> mnesia:table_info(tTest, size) end, 
[], mnesia_frag).
1
[T || T <- ([tTest] ++ [list_to_atom("tTest_frag" ++ integer_to_list(N)) 
|| N <- lists:seq(2, 10)]), mnesia:table_info(T, size) > 0].
[tTest_frag2]
ets:tab2list(tTest_frag2).
[#testCounter{key = 100,value = 200}]

*We have 1 record in table in frag: tTest_frag2*

Now please "insert" record using mnesia:dirty_update_counter/3:

[mnesia:clear_table(T) || T <- ([tTest] ++ [list_to_atom("tTest_frag" ++ 
integer_to_list(N)) || N <- lists:seq(2, 10)])].
[{atomic,ok},
  {atomic,ok},
  {atomic,ok},
  {atomic,ok},
  {atomic,ok},
  {atomic,ok},
  {atomic,ok},
  {atomic,ok},
  {atomic,ok},
  {atomic,ok}]
mnesia:activity(sync_dirty, fun()-> mnesia:table_info(tTest, size) end, 
[], mnesia_frag).
0
mnesia:activity(sync_dirty, fun() -> mnesia:dirty_update_counter(tTest, 
100, 200) end, [], mnesia_frag).
200
mnesia:activity(sync_dirty, fun()-> mnesia:table_info(tTest, size) end, 
[], mnesia_frag).
1
[T || T <- ([tTest] ++ [list_to_atom("tTest_frag" ++ integer_to_list(N)) 
|| N <- lists:seq(2, 10)]), mnesia:table_info(T, size) > 0].
[tTest]
ets:tab2list(tTest).
[#testCounter{key = 100,value = 200}]

*Now record goes to 1st frag: tTest*

So it looks, that dirty_update_counter doesn't handle frag table properly.

Best regards
Aleksander Nycz

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20150710/e49ebbd2/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4936 bytes
Desc: Kryptograficzna sygnatura S/MIME
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20150710/e49ebbd2/attachment.bin>


More information about the erlang-bugs mailing list