<div>Can you send me (privately) a small test program that shows the problem.</div><div><br></div><div><br></div>/Dan<br><br><div class="gmail_quote">On Fri, Jul 8, 2011 at 10:30 AM, karol skocik <span dir="ltr"><<a href="mailto:karol.skocik@gmail.com">karol.skocik@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">In addition to this, the obvious question:<br>
what should I do to ensure that schema change is propagated after<br>
mnesia:add_table_copy?<br>
<br>
Or alternatively, what should I call **before**<br>
mnesia:table_info(Table, disc_copies) to get all nodes where the copy<br>
resides?<br>
<br>
Thanks for any suggestions,<br>
<font color="#888888">Karol<br>
</font><div><div></div><div class="h5"><br>
On Thu, Jul 7, 2011 at 7:01 PM, karol skocik <<a href="mailto:karol.skocik@gmail.com">karol.skocik@gmail.com</a>> wrote:<br>
> Hi,<br>
> I think I have found a race condition in mnesia:add_table_copy.<br>
> I am trying to add table copy, when new node appears in cluster (or<br>
> add table copy to another node, when the one having a copy fails), and<br>
> the number of copies is less than some required count.<br>
><br>
> The idea is simple, I spawn a new process on every node in cluster<br>
> first, and in these processes I want to create a global transaction<br>
> using global:trans with ID = {add_table_trans, table_name}.<br>
> The first process which grabbed the transaction lock, checks if more<br>
> table copies are required, and creates new copy on some node not<br>
> having one, when needed.<br>
> When the copy is created, this process exits, and another process on<br>
> different node gets the transaction lock and tries to do the same.<br>
><br>
> The problem here is, that the second process checks where are the<br>
> copies using mnesia:table_info(table_name, disc_copies), and this list<br>
> is sometimes incomplete, missing the very last node which got a table<br>
> copy in the first process.<br>
> It can be verified easily - in the second process:<br>
> Copies1 = mnesia:table_info(table_name, disc_copies),<br>
> timer:sleep(2000),<br>
> Copies2 = mnesia:table_info(table_name, disc_copies).<br>
><br>
> Then, mnesia:add_table_copy fails with<br>
> {aborted,{already_exists,table_name,LastAddedNode}}<br>
><br>
> Since the transaction lock ensures that no other process can add<br>
> another table copy, I guess this is a race condition where new table<br>
> copy node is not propagated to the schema on all nodes before the<br>
> function mnesia:add_table_copy returns.<br>
><br>
> Karol<br>
><br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br>