<div dir="ltr"><div><div><div>This thread makes we wonder about the following section in the Mnesia documentation:<br><br>"If a power
failure occurs during the dump, this can cause the randomly
accessed <span class="inbox-inbox-code">DAT</span> files to become corrupt. If the parameter
is set to <span class="inbox-inbox-code">false</span>, <span class="inbox-inbox-code">Mnesia</span> copies the <span class="inbox-inbox-code">DAT</span>
files and target the dump
to the new temporary files. If the dump is successful, the
temporary files are renamed to their normal <span class="inbox-inbox-code">DAT</span>
suffixes. The possibility for unrecoverable inconsistencies in
the data files becomes much smaller with this strategy.
However, the actual dumping of the transaction log becomes
considerably slower. The system designer must decide whether
speed or safety is the higher priority."<br><br></div>In UNIX(Posix) a rename(2) call is atomic. The worst case, which is an OS crash might leave you with a temporary file and the target file, hardlinked as if ln() was called, but the move itself is atomic, even under OS crashes. Of course, this assumes you correctly wrote your temporary file, fsync()'ed the file and then performed the rename() as you should.<br><br></div>With that information in mind, what is the scenario which can make mnesia fail if the dump_log_update_in_place is set to false? There may be a window, but the operating system cannot be the provider of this window at all, unless it is incorrectly implemented or configured[1]. Hence my question.<br><br></div>[1] The primary concern are write caches on disks which can have a write hole unless they have proper (working!) battery backup of their cache or are able to write their memory to a small solid state part of the chip. Or if you are using ZFS where copy-on-write semantics completely eliminates the write hole.<br><div><div><div><div><br><br></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Nov 22, 2017 at 2:29 PM Michael Schmidt <<a href="mailto:Michael.K.Schmidt@schneider-electric.com">Michael.K.Schmidt@schneider-electric.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="m_-46381732065610871WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext">Hi Arun,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext">If you happen to reboot when Mnesia is writing out its logfile, it can become corrupt (and lose data). We fight this issue on embedded devices a lot.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext">Look “Configuration Parameters” section here:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext"><a href="http://erlang.org/doc/man/mnesia.html#id69584" target="_blank">http://erlang.org/doc/man/mnesia.html#id69584</a><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext">You will want to set
</span><span style="font-family:Courier;color:#1a1a1a;background:#f3f3f3">dump_log_update_in_place</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext"> to false. This will make it write out the table to a new file, and rename
it the very end. <u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext">One other option to look at is
</span><span style="font-family:Courier;color:#1a1a1a;background:#f3f3f3">dump_log_time_threshold</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext"> to change how often items are flushed to disk. For configuration data,
you can likely set this to a few seconds.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext">These options can be set via the sys.config file as well<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext">Mike<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext"><u></u> <u></u></span></p>
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext"> <a href="mailto:erlang-questions-bounces@erlang.org" target="_blank">erlang-questions-bounces@erlang.org</a> [mailto:<a href="mailto:erlang-questions-bounces@erlang.org" target="_blank">erlang-questions-bounces@erlang.org</a>]
<b>On Behalf Of </b>Arun<br>
<b>Sent:</b> Tuesday, November 21, 2017 10:16 PM<br>
<b>To:</b> <a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<b>Subject:</b> [erlang-questions] Mnesia deleting log file<u></u><u></u></span></p>
</div>
</div></div></div><div bgcolor="white" lang="EN-US" link="blue" vlink="purple"><div class="m_-46381732065610871WordSection1">
<p class="MsoNormal"><u></u> <u></u></p>
<p>Dear all,<u></u><u></u></p>
<p>I've a program written in erlang which uses Mnesia application as the database application. I've a table created by name "configuration_table" which stores<u></u><u></u></p>
<p>certain configurations that need to be persistent. Occasionally, whenever I restart my program the following error is thrown by mnesia and I end up losing<u></u><u></u></p>
<p>all the persistent configurations. <u></u><u></u></p>
<p>I've searched about this problem in the erlang documentation and all it tells is "Node not running". What could be the probable cause for this problem<u></u><u></u></p>
<p>and how do I fix it?<u></u><u></u></p>
<p>Mnesia('<a href="mailto:ommp82_plus@10.1.4.16" target="_blank">test@10.1.4.16</a>'): Data may be missing, Corrupt logfile deleted: "/home/utl/mnesia_database/configuration_table.DCL", {node_not_running,
<br>
'test<a href="mailto:ommp82_plus@10.1.4.16" target="_blank">@10.1.4.16</a>'} <u></u><u></u></p>
</div></div><div bgcolor="white" lang="EN-US" link="blue" vlink="purple"><div class="m_-46381732065610871WordSection1"><p class="MsoNormal"><br>
______________________________________________________________________<br>
This email has been scanned by the Symantec Email Security.cloud service.<br>
______________________________________________________________________<u></u><u></u></p>
</div>
</div>
_______________________________________________<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" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div>