1

When I create a fragmented table in Mnesia, all of the table fragments will have the suffix _fragN except for the first fragment. This is error-prone, since any code that accesses the table without specifying the correct access module will appear to work, since it reads from and writes to the first fragment, but it will not mix with code using the correct access module, since they will be looking for elements in different places.

Is there a way to tell Mnesia to use a fragment suffix for all table fragments? That would avoid that problem, by making incorrect accesses fail noisily.


For example, if I create a table with four fragments:

1> mnesia:start().
ok
2> mnesia:create_table(foo, [{frag_properties, [{node_pool, [node()]}, {n_fragments, 4}]}]). 
{atomic,ok}

then mnesia:info/0 will list the fragments as foo, foo_frag2, foo_frag3 and foo_frag4:

3> mnesia:info().
---> Processes holding locks <--- 
---> Processes waiting for locks <--- 
---> Participant transactions <--- 
---> Coordinator transactions <---
---> Uncertain transactions <--- 
---> Active tables <--- 
foo            : with 0        records occupying 304      words of mem
foo_frag2      : with 0        records occupying 304      words of mem
foo_frag3      : with 0        records occupying 304      words of mem
foo_frag4      : with 0        records occupying 304      words of mem
schema         : with 5        records occupying 950      words of mem
===> System info in version "4.14", debug level = none <===
opt_disc. Directory "/Users/legoscia/Mnesia.nonode@nohost" is NOT used.
use fallback at restart = false
running db nodes   = [nonode@nohost]
stopped db nodes   = [] 
master node tables = []
remote             = []
ram_copies         = [foo,foo_frag2,foo_frag3,foo_frag4,schema]
disc_copies        = []
disc_only_copies   = []
[{nonode@nohost,ram_copies}] = [schema,foo_frag4,foo_frag3,foo_frag2,foo]
3 transactions committed, 0 aborted, 0 restarted, 0 logged to disc
0 held locks, 0 in queue; 0 local transactions, 0 remote
0 transactions waits for other nodes: []

I'd want foo to be foo_frag1 instead. Is that possible?

legoscia
  • 39,593
  • 22
  • 116
  • 167

0 Answers0