[erlang-questions] In a mnesia cluster, which node is queried?

Dan Gudmundsson dgud@REDACTED
Tue Apr 7 16:51:29 CEST 2009


Like this

from mnesia_lib:
set_remote_where_to_read(Tab, Ignore) ->
     Active = val({Tab, active_replicas}),
     Valid =
	case mnesia_recover:get_master_nodes(Tab) of
	    [] ->  Active;
	    Masters -> mnesia_lib:intersect(Masters, Active)
	end,
     Available = mnesia_lib:intersect(val({current, db_nodes}), Valid -- Ignore),
     DiscOnlyC = val({Tab, disc_only_copies}),
     Prefered  = Available -- DiscOnlyC,
     if
	Prefered /= [] ->
	    set({Tab, where_to_read}, hd(Prefered));
	Available /= [] ->
	    set({Tab, where_to_read}, hd(Available));
	true ->
	    set({Tab, where_to_read}, nowhere)
     end.



ryeguy wrote:
> I reposted this question elsewhere, and I worded it differently. Here
> is my reworded question if it makes it more clear:
> 
> Let's say you have a mnesia table replicated on nodes A and B. If on
> node C, which does not contain a copy of the table, I do
> mnesia:change_config(extra_db_nodes, [NodeA, NodeB]), and then on node
> C I do mnesia:dirty_read(user, bob) how does node C choose which
> node's copy of the table to execute a query on?
> 
> On Apr 6, 10:11 pm, ryeguy <ryeg...@REDACTED> wrote:
>> If you have a mnesia table replicated on nodes A and B, how does node
>> C (which does not contain a copy of the table) choose which table to
>> execute a query on? Is it random?
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
> 



More information about the erlang-questions mailing list