<div dir="ltr">Hello,<div><br></div><div>on Erlang R16B02 (also in previous versions) I've found that mnesia:dirty_update_counter return 'ok' instead of integer when I subscribed on detailed events for the "update counter's" table.</div>
<div><br></div><div>Example:</div><div><br></div><div><div>1> mnesia:start().</div><div>ok</div><div>2> mnesia:create_table(update_counter_table, [{ram_copies, [node()]}, {attributes, [key, counter]}]).</div><div>{atomic,ok}</div>
<div>3> mnesia:dirty_update_counter(update_counter_table, key1, 1).</div><div>1</div><div>4> mnesia:dirty_update_counter(update_counter_table, key1, 1).</div><div>2</div><div>5> mnesia:dirty_update_counter(update_counter_table, key1, 1).</div>
<div>3</div></div><div><br></div><div>6> mnesia:subscribe({table, update_counter_table, detailed}).<br></div><div><div>{ok,nonode@nohost}</div><div>7> mnesia:dirty_update_counter(update_counter_table, key2, 1).</div>
<div>ok</div><div>8> mnesia:dirty_update_counter(update_counter_table, key2, 1).</div><div>ok</div><div>9> mnesia:dirty_update_counter(update_counter_table, key2, 1).</div><div>ok</div></div><div><br></div><div>I have chaned code of mnesia and found that in mnesia_tm:1790 catched error with reason:</div>
<div><br></div><div><div>{function_clause,</div><div>[{mnesia_subscr,what,</div><div> [update_counter_table,</div><div> {dirty,<0.33.0>},</div><div> {update_counter_table,key1,10},</div><div> write,</div>
<div> [{update_counter_table,key1,9}]],</div><div> [{file,"mnesia_subscr.erl"},{line,188}]},</div><div> {mnesia_subscr,report_table_event,6,</div><div> [{file,"mnesia_subscr.erl"},{line,172}]},</div>
<div> {mnesia_tm,commit_update,6,</div><div> [{file,"mnesia_tm.erl"},{line,1865}]},</div><div> {mnesia_tm,do_update_op,3,</div><div> [{file,"mnesia_tm.erl"},{line,1833}]},</div><div> {mnesia_tm,do_update,4,[{file,"mnesia_tm.erl"},{line,1790}]},</div>
<div> {mnesia_tm,do_commit,3,[{file,"mnesia_tm.erl"},{line,1782}]},</div><div> {mnesia_tm,async_send_dirty,6,</div><div> [{file,"mnesia_tm.erl"},{line,1994}]},</div><div> {mnesia_tm,dirty,2,[{file,"mnesia_tm.erl"},{line,1077}]}]}.</div>
</div><div><br></div><div><br></div><div>The problem in the mnesia_subscr, It try prepare event for update_counter like for write, but doesn't expect that Old row value may be NOT undefined (like in case with update_counter).</div>
<div><br></div><div>Anton</div></div>