2
votes

How can I tell the difference between a table not being present in the schema and a table that has not yet loaded?

I am currently using mnesia:wait_for_tables() with a relatively large timeout to detect a table, but this is loose (what happens if the table actually takes a long time to start) and time consuming (if the table is really not there).

2

2 Answers

1
votes

Maybe try...

lists:member(table_name, mnesia:table_info(schema, tables)).

It's only a guess, but it could be the basis for an experiment if no one else has a definitive answer.

1
votes

mnesia:table_info/2 may help.

  1. If you know the table names in advance and you want to know which nodes have data,

    mnesia:table_info(TableName, StorageType).
    

    StorageType should be one of

    ram_copies, disc_copies or disc_only_copies.
    
  2. or, if you want to know the local node has table copy, just

    mnesia:table_info(TableName, storage_type).
    

    If the local node does NOT have a copy, this returns 'unknown'.