Mnesia fragmentation of external storage (leveldb) tables?

Howdy all, it’s been a while!

Has anyone managed to use Mnesia fragmented tables with external storage tables? I’m currently using OTP 29.1.1 (erts-17.1, according to erlang:system_info(system_version).

I was playing around with mnesia_eleveldb and created a table using leveldb_copies as the storage type. I can read from and write to this table so it all appears to be correct.

I can turn on fragmentation for the table using the usual mnesia:change_table_frag(mytable, {activate, []}) method and this doesn’t throw up any immediate issues. I can continue to write new records to and read new and existing records from a single-fragment “fragmented” leveldb_copies table.

But when I attempt to add a fragment with the expected mnesia:change_table_frag(mytable, {add_frag, [node()]}) command on this table I am hit with a function_clause error from within the depths of mnesia_schema:

** exception error: no match of right hand side value {aborted,
 {function_clause,
  [{mnesia_schema,'-verify_nodes/1-inlined-1-',
    [nonode@nohost],
    [{file,"mnesia_schema.erl"},{line,1250}]},
   {lists,foreach_1,2,[{file,"lists.erl"},{line,2641}]},
   {mnesia_schema,verify_nodes,1,
    [{file,"mnesia_schema.erl"},{line,1249}]},
   {mnesia_schema,assert_correct_cstruct,1,
    [{file,"mnesia_schema.erl"},{line,1107}]},
   {mnesia_schema,verify_cstruct,1,
    [{file,"mnesia_schema.erl"},{line,1023}]},
   {mnesia_schema,unsafe_make_create_table,1,
    [{file,"mnesia_schema.erl"},{line,1561}]},
   {mnesia_frag,make_add_frag,2,
    [{file,"mnesia_frag.erl"},{line,873}]},
   {mnesia_frag,make_multi_add_frag,2,
    [{file,"mnesia_frag.erl"},{line,820}]}]}}

Changing the storage type of the table to ram_copies or disc_copies instead of leveldb_copies lets the above commands work, and I’m able to create however many fragments I like, as usual. As far as I can tell from looking at the mnesia_frag.erl and mnesia_schema.erl files it seems that external storage tables are supposed to be supported, so maybe I’m not setting the add_frag options correctly for this table storage type?

Thanks,

Phil

i suspect this one is a backend limitation rather than your call being wrong. the fact the exact same sequence works on ram_copies and disc_copies points that way, fragmentation was built around the built in storage types and eleveldb plugs in underneath that layer. most folks i have seen hit this end up sharding manually instead, a handful of separate leveldb tables and hash the key in your own code to pick one. not as neat as frag tables, but it avoids the schema code path that is falling over here.