I have a mnesia cluster running on four nodes. A table name student exists with 7 fragments. According to the mnesia doc, when reading, mnesia determines from which of the fragments the record belongs, from the hash value of the key; the read is to be done through the mnesia:activity/4 function. To test the partitioning, I inserted 512 records with keys from 1-512. I look at the size attributes of the fragmented table from mnesia:table_info/2 in mnesia:activity/4 context; this confirms that the fragments has 512 records. The problem is, when I read a record with a key ranging from(1-512) which does exists in the table, I only retrieved a record if that key is in the range of keys existing in the first fragment. In other words, mnesia is reading only from the first fragment. Don't know what i have done wrong. Please I need your help. Thanks
0
votes
1 Answers
0
votes
I found the problem. I was using mnesia dirty read operations as the functional object parameter to the mnesia:activity/4 function. I observerd that this function shouldn't be a dirty operation since the context can be determine by the AccessContext parameter. Eg.
This reads from only the first fragment:
KeysFun = fun () -> mnesia:dirty_all_keys(Tab) end,
mnesia:activity(sync_dirty, KeysFun,[],mod_frag).
This reads from all fragments:
KeysFun = fun () -> mnesia:all_keys(Tab) end,
mnesia:activity(sync_dirty, KeysFun,[],mod_frag).