Sebastian,<div><br></div><div>I don&#39;t think the problem is specific to rrdcached; it uses normal librrd API.  This problem likely affects any RRD access in a memory constrained system.</div><div><br></div><div>Is there a lack of memory (or address space if 32-bit) on the system?  Or is it running up against per-process limits?</div>

<div><br></div><div>How does the file end up?  Is it the right size?  What errors do you get (i.e. when you &quot;rrdtool info&quot;).  What architecture are you running on?  mmap() under failure conditions is likely to be OS-specific.</div>

<div><br></div><div>What revision of trunk?</div><div><br></div><div>Let us know what you find re: memory leak.</div><div><br></div><div>-kb<br><br><div class="gmail_quote">On Thu, Oct 21, 2010 at 5:07 PM, Steve Shipway <span dir="ltr">&lt;<a href="mailto:s.shipway@auckland.ac.nz">s.shipway@auckland.ac.nz</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">









<div lang="EN-NZ" link="blue" vlink="purple">

<div>

<p class="MsoNormal">I’ve had this happen too often now for it to be a fluke. 
OK, so I’m using the trunk version of rrdtool 1.4, but (as far as I know)
there is nothing in there to modify the update code.  We have a high
update frequency – approx. 20,000 MRTG targets at 5min intervals, which
equates to about 70 updates per second, and it took about a week for the
problem to first hit.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">It seems that something is happening on update, possibly involving
memory allocation failure, that results in a corrupted file.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">I have some processes that may be reading the file without
using the rrdcached, but all updates are certainly going this way (no data
collection is run on this server any more, it all comes over TCP)</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Selected error logs show:</p>

<p class="MsoNormal">listen_thread_main: pthread_create failed.</p>

<p class="MsoNormal">queue_thread_main: rrd_update_r (/u01/rrdtool/maildelivery-mx1.rrd)
failed with status -1. (mmaping file &#39;/u01/rrdtool/maildelivery-mx1.rrd&#39;:
Cannot allocate memory)</p>

<p class="MsoNormal"><i>   (restarted rrdcached here)</i></p>

<p class="MsoNormal">replaying from journal: /u01/rrdtool/journal/rrd.journal.1285603416.766523</p>

<p class="MsoNormal">Replayed 61011 entries (0 failures)</p>

<p class="MsoNormal">replaying from journal: /u01/rrdtool/journal/rrd.journal.1285607016.766153</p>

<p class="MsoNormal">Malformed journal entry at line 31024</p>

<p class="MsoNormal">Replayed 31023 entries (1 failures)</p>

<p class="MsoNormal">journal processing complete</p>

<p class="MsoNormal">queue_thread_main: rrd_update_r
(/u01/rrdtool/maildelivery-mx1.rrd) failed with status -1.
(&#39;/u01/rrdtool/maildelivery-mx1.rrd&#39; is not an RRD file)</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Although there was only one journal failure, there were in
fact several RRD files corrupted (I suspect the ones which were open at the
time of the memory failure?) and even more with the rrd_update_r memory allocation
failure.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">It seems that the memory ran out (memory leak?) and somewhere
in the rrd_update_r something was half-done.  The resultant corrupted RRD
file doesn’t even load in rrdtool, seems the header is corrupt – I don’t
(yet) understand enough of the mmap code to work out what could be causing
this.  I’m also trying to track the memory usage of the rrdcached
process to see if it is indeed growing due to a leak.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">I think there are two bugs here – first, the memory
leak causing the failure, and second, something in the code is not correctly
handling a memory allocation failure and corrupts the RRD file as a result.</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Has anyone else experienced this?  And, more to the
point, any RRD developers who understand the MMAP update code want to take a
look or give some pointers?</p>

<p class="MsoNormal"> </p>

<p class="MsoNormal">Steve</p>

<p class="MsoNormal"> </p>

<div class="MsoNormal" align="center" style="text-align:center"><span lang="EN-US">

<hr size="2" width="100%" align="center">

</span></div>

<p class="MsoNormal"><b>Steve Shipway</b></p>

<p class="MsoNormal"><span style="font-size:10.0pt">ITS Unix Services Design Lead</span></p>

<p class="MsoNormal"><span style="font-size:10.0pt">University of Auckland, New
Zealand</span></p>

<p class="MsoNormal"><span style="font-size:10.0pt">Floor 1, 58 Symonds Street,
Auckland</span></p>

<p class="MsoNormal"><i><span style="font-size:10.0pt;color:#595959">Phone: +64
(0)9 3737599 ext 86487</span></i></p>

<p class="MsoNormal"><i><span style="font-size:10.0pt;color:#595959">DDI: +64
(0)9 924 6487</span></i></p>

<p class="MsoNormal"><i><span style="font-size:10.0pt;color:#595959">Mobile: +64
(0)21 753 189</span></i></p>

<p class="MsoNormal"><i><span style="font-size:10.0pt;color:#595959">Email: <a href="mailto:s.shipway@auckland.ac.nz" target="_blank"><span style="color:#595959">s.shipway@auckland.ac.nz</span></a></span></i></p>

<p class="MsoNormal"><span lang="EN-GB" style="font-size:18.0pt;font-family:Webdings;color:green">P</span><span lang="EN-GB" style="color:blue"> </span><span lang="EN-GB" style="font-size:10.0pt;color:green">Please consider the environment before printing this e-mail</span><span lang="EN-GB" style="color:blue"> </span><span lang="EN-GB" style="font-size:7.5pt;color:navy"></span></p>



<p class="MsoNormal"><i><span style="font-size:10.0pt"> </span></i></p>

<p class="MsoNormal"> </p>

</div>

</div>


<br>_______________________________________________<br>
rrd-developers mailing list<br>
<a href="mailto:rrd-developers@lists.oetiker.ch">rrd-developers@lists.oetiker.ch</a><br>
<a href="https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers" target="_blank">https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br> kevin brintnall =~ /<a href="http://kbrint@rufus.net/">kbrint@rufus.net/</a><br><br>
</div>