<div dir="ltr">Hi Janos, <div style>In my view, the main purpose for mnesia is being in-memory distributed database, not a complete RDBMS replacement.</div><div style><br></div><div style>There are some projects to user different backends than DETS for mnesia (for persistence data).</div>
<div style>One project was to a framework for mnesia pluggable backends (based on earlier work of Ulf Wiger on mnesia_ext_filesystem). The first plugin was based on LevelDB. </div><div style>It was presented in EUC 2012</div>
<div style><a href="http://www.erlang-factory.com/conference/ErlangUserConference2012/speakers/RolandKarlsson">http://www.erlang-factory.com/conference/ErlangUserConference2012/speakers/RolandKarlsson</a><br></div><div style>
<br></div><div style>I'm not sure about the project status right now.</div><div style><br></div><div style>Best Regards, </div><div style>Ahmed</div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Wed, Sep 4, 2013 at 4:19 PM, Janos Hary <span dir="ltr"><<a href="mailto:janos.n.hary@gmail.com" target="_blank">janos.n.hary@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">Ahmed,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">Thanks for the detailed explanation. <u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">As per <a href="http://www.erlang.org/doc/apps/mnesia/Mnesia_chap4.html" target="_blank">http://www.erlang.org/doc/apps/mnesia/Mnesia_chap4.html</a> :<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">“Durability. This transaction property ensures that changes made to the DBMS by a transaction are permanent. Once a transaction has been committed, all changes made to the database are durable - i.e. they are written safely to disc and will not be corrupted or disappear.”<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">I would definitely expect {aborted, Reason} in case of a storage operation failure. <u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">Since then I found another occurrence of this problem. If I’m precautious and put my data in fragmented table, but have a secondary index, that index will still kept in a single dets file. In my case I tried to index SHA hashes and the index grows pretty fast.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">Thanks again for your answer, even if it was a bad news for me. Mnesia looks to be a great database, but I think it was a mistake from my side to try using it as a complete RDBMS replacement.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">Best Regards,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">Tamas<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Ahmed Omar [mailto:<a href="mailto:spawn.think@gmail.com" target="_blank">spawn.think@gmail.com</a>] <br>
<b>Sent:</b> Wednesday, September 04, 2013 2:25 PM<br><b>To:</b> Janos Hary<br><b>Cc:</b> erlang-questions; Håkan Mattsson</span></p><div><div class="h5"><br><b>Subject:</b> Re: [erlang-questions] mnesia silent failure and table corruption<u></u><u></u></div>
</div><p></p><div><div class="h5"><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">Hi Janos, <u></u><u></u></p><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Indeed, in that case transactions could be considered succeeded while actual storage operation failed...<u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">The thing is, If mnesia needs to write data to a store (in this case dets), it doesn't check for results for this operation. Actually, it does even catch exceptions. (mnesia_tm:do_update/4)<u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">As dets have a maximum of 2GB for file size, I believe the table gets corrupted after that. (somebody correct me please)<u></u><u></u></p>
</div><div><p class="MsoNormal">So any operation on that dets table will return the bad_object error.<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">So the commit is considered succeeded, mnesia logs it, transaction returns {atomic, ok}<u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">sync_transaction won't help, because it just waits for the commit to be synced/logged, but also doesn't check results of the store operation.<u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">so you could end up in situation where dirty write operation returns an error, and in a transaction returns {atomic, ok}<u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><div><p class="MsoNormal">> dets:insert(table1, SomeKey, SomeVal).<u></u><u></u></p></div><div><p class="MsoNormal">{error,{{bad_object,read_buckets},<u></u><u></u></p>
</div><div><p class="MsoNormal">        "/tmp/table1.DAT"}}<u></u><u></u></p></div></div><div><div><p class="MsoNormal">> mnesia:dirty_write(SomeRecord).<u></u><u></u></p></div><div><p class="MsoNormal">{error,{{bad_object,read_buckets},<u></u><u></u></p>
</div><div><p class="MsoNormal">        "/tmp/table1.DAT"}}<u></u><u></u></p></div><div><p class="MsoNormal">> mnesia:transaction(fun()-> mnesia:write(SomeRecord) end).  <u></u><u></u></p></div><div><p class="MsoNormal">
{atomic,ok}<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">You could try to detect that in your transaction by adding an operation that will fail (like read, first, last, ..etc) but that won't protect you against corrupting the file.<u></u><u></u></p>
</div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">The question is, should mnesia detect this kind of errors and if yes, what to do about it?<u></u><u></u></p>
</div><div><p class="MsoNormal">Also, can dets protect against the corruption somehow? (reject the operation that could lead to size> 2GB?)<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div>
<p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Best Regards, <u></u><u></u></p></div><div><p class="MsoNormal">Ahmed<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div></div>
</div><div><p class="MsoNormal" style="margin-bottom:12.0pt"><u></u> <u></u></p><div><p class="MsoNormal">On Tue, Aug 27, 2013 at 5:06 PM, Janos Hary <<a href="mailto:janos.n.hary@gmail.com" target="_blank">janos.n.hary@gmail.com</a>> wrote:<u></u><u></u></p>
<p class="MsoNormal">Thanks, but no luck. It behaves the same with sync_transaction.<br><span style="color:#888888"><br><span>Janos</span></span><u></u><u></u></p><div><div><p class="MsoNormal"><br>-----Original Message-----<br>
From: <a href="mailto:hawk.mattsson@gmail.com" target="_blank">hawk.mattsson@gmail.com</a> [mailto:<a href="mailto:hawk.mattsson@gmail.com" target="_blank">hawk.mattsson@gmail.com</a>] On Behalf Of<br>Håkan Mattsson<br>Sent: Tuesday, August 27, 2013 4:02 PM<br>
To: Janos Hary<br>Cc: erlang-questions<br>Subject: Re: [erlang-questions] mnesia silent failure and table corruption<br><br>On Tue, Aug 27, 2013 at 3:05 PM, Janos Hary <<a href="mailto:janos.n.hary@gmail.com" target="_blank">janos.n.hary@gmail.com</a>> wrote:<br>
> All,<br>><br>> I started to write records into a table from a simple test function.<br>> When the table size reaches 2GB write transactions still report<br>> success, but they are silently ignored. The table became unusable,<br>
> read operations return error, and mnesia cannot recover the table. How<br>> shall I avoid such situation?<br><br>Try using mnesia:sync_transaction() instead of mnesia:transaction().<br>Then Mnesia will use syncronized calls to disk_log (and syncronized commits<br>
when several nodes are involved).<br><br>/Håkan<br><br>_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><u></u><u></u></p></div></div></div><p class="MsoNormal"><u></u> <u></u></p></div></div>
</div></div></div></blockquote></div><br></div>