[erlang-questions] mnesia:table_info(Table, size) returns 0 for remote tables
Serge Aleynikov
saleyn@REDACTED
Thu Jun 5 13:35:58 CEST 2008
Is this any better than doing:
Node = mnesia:table_info(Table, where_to_read),
rpc:call(Node, mnesia, table_info, [Table, size]).
I think that
mnesia:activity(transaction,fun() -> mnesia:table_info(t2,size)
end,mnesia_frag).
boils down to the rpc call anyway. Though it looks like a simple call
to mnesia:table_info(Table, size) that would abstract implementation
details of where the table is would be cleaner.
Serge
Ulf Wiger (TN/EAB) wrote:
> Serge Aleynikov wrote:
>> I ran into this non-intuitive behavior of the mnesia:table_info(Table,
>> size) function. Unlike other calls of the mnesia:table_info/2 family
>> this one returns 0 if a table is not local.
>>
>> The work around is to do:
>> Node = mnesia:table_info(Table, where_to_read),
>> rpc:call(Node, mnesia, table_info, [Table, size]).
>>
>> Though, it's not clear to me why the caller of mnesia:table_info/2 has
>> to go though this trouble. Can this be fixed?
>>
>> Serge
>>
>
> You can use the mnesia_frag callback:
>
> Eshell V5.5.4 (abort with ^G)
> (m1@REDACTED)1> mnesia:start().
> ok
> (m1@REDACTED)2> mnesia:create_table(t2,[{ram_copies,[m2@REDACTED]}]).
> {atomic,ok}
> (m1@REDACTED)3> mnesia:table_info(t2,size).
> 0
> (m1@REDACTED)4> mnesia:activity(transaction,fun() ->
> mnesia:table_info(t2,size) end,mnesia_frag).
> 1
> (m1@REDACTED)5>
>
>
> BR,
> Ulf W
>
More information about the erlang-questions
mailing list