<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7653.38">
<TITLE>RE: [sqlite] experiencing SQLite crash (Apache/mod_perl/Catalyst)</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<BR>

<P><FONT SIZE=2 FACE="Courier New">&gt;Hi all,</FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;</FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;I have a Perl Catalyst app using SQLite as storage. It has been running</FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;for several months without any problem.</FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;Now in the last few days we had several crashes of SQLite (file gets</FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;corrupted). This is just incomprehensible because all development and</FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;production engineers claim that nothing has changed in </FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;application code,</FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;nor in Catalyst, DBD::Sqlite, Apache, or operating system </FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;(Solaris), and</FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;we can't reproduce the problem in dev. So we don't even know where to</FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;start our investigations.</FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;</FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;Any hints, suggestions, related info, etc. would be welcome.</FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;</FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;The production server is running Apache 2.2.8 Solaris / mod_perl 2.04 /</FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;Perl 5.7.8 / Catalyst 5.7007 / DBD::SQlite 1.13.</FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;</FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;Thanks in advance, </FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;</FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Laurent Dami</FONT>

<BR><FONT SIZE=2 FACE="Courier New">&gt;</FONT>
</P>
<BR>

<P><FONT SIZE=2 FACE="Courier New">For info : we partially understood the problem.</FONT>
</P>

<P><FONT SIZE=2 FACE="Courier New">The production server uses a private Apache authentication module written in C.</FONT>

<BR><FONT SIZE=2 FACE="Courier New">That module was accidentally compiled with a debug flag and therefore was sending</FONT>

<BR><FONT SIZE=2 FACE="Courier New">printf(..) statements to STDOUT (probably a very bad idea, instead of</FONT>

<BR><FONT SIZE=2 FACE="Courier New">going through Apache logging methods!). </FONT>

<BR><FONT SIZE=2 FACE="Courier New">This went undetected for several months -- the printf were written God knows where.</FONT>
</P>

<P><FONT SIZE=2 FACE="Courier New">What happened in the last few days is that in some occasions the file descriptor</FONT>

<BR><FONT SIZE=2 FACE="Courier New">for accessing SQLite was the same as the stdout used by C printf --</FONT>

<BR><FONT SIZE=2 FACE="Courier New">so some logging data was overwriting some blocks inside the SQLite binary file!</FONT>

<BR><FONT SIZE=2 FACE="Courier New">No idea if this sharing of file descriptor is because of Apache or mod_perl or </FONT>

<BR><FONT SIZE=2 FACE="Courier New">DBD::Sqlite or still something else, nor why this sharing only started a few</FONT>

<BR><FONT SIZE=2 FACE="Courier New">days ago&nbsp; (maybe a difference in load of the server).</FONT>
</P>

<P><FONT SIZE=2 FACE="Courier New">Anyway, the fix is of course to disable debug flag in that C module, so that</FONT>

<BR><FONT SIZE=2 FACE="Courier New">it no longer prints to stdout.</FONT>
</P>

<P><FONT SIZE=2 FACE="Courier New">Many thanks to people who responded to my previous call for help.</FONT>
</P>

<P><FONT SIZE=2 FACE="Courier New">Best regards,</FONT>
</P>

<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT SIZE=2 FACE="Courier New">Laurent Dami</FONT>
</P>
<BR>
<BR>
<BR>
<BR>
<BR>
<BR>

</BODY>
</HTML>