update: davido pointed me to the documentation that states that separate processes sharing a single DB handle will almost certainly cause issues. I changed my code so that each event (process) uses its own DB handle, which all point to the same SQLite database. After that, I've got 19+ hours of successful runtime, so it seems to be resolved./update

I've got a long-running web app with Dancer2 that has asynchronous processes doing DB work outside of the main process.

I've been trying to sort out why the event crashes, and after dumping the web access requests to /dev/null, adding some debug printing in the C code that reads a sensor and updates a DB, I finally got what I was looking for. In the below error, it's reading the sensor until it gets a valid value for temp and humidity, and then the C code passes back the values to Perl. Perl then (still inside of an async event), writes these values to the DB.

However, all I can find on the error "file is encrypted..." is related to version mis-matches etc. I can't see that being the case here, because my app was running for 2.5+ hours, then broke suddenly. The web app is still running, but this event is crashed, so no more updates.

Could this be a clash of file access or something? Anyone seen this before?

DHT11 exec temp temp data: -1 temp data: 21 temp: 21 DHT11 exec humidity humidity data: -1 humidity data: -1 humidity data: -1 humidity data: -1 humidity data: -1 humidity data: 20 humidity: 20 DBD::SQLite::st execute failed: file is encrypted or is not a database + at /home/pi/repos/app-envui/bin/../lib/App/RPi/EnvUI/DB.pm line 66. DBD::SQLite::st execute failed: database disk image is malformed at /h +ome/pi/repos/app-envui/bin/../lib/App/RPi/EnvUI/DB.pm line 95. Error while loading /home/pi/repos/app-envui/bin/app.pl: DBD::SQLite:: +st execute failed: database disk image is malformed at /home/pi/repos +/app-envui/bin/../lib/App/RPi/EnvUI/DB.pm line 95. Compilation failed in require at /home/pi/repos/app-envui/bin/app.pl l +ine 8. BEGIN failed--compilation aborted at /home/pi/repos/app-envui/bin/app. +pl line 8. [App::RPi::EnvUI:7104] error @2016-10-09 13:39:58> Route exception: DB +D::SQLite::st execute failed: file is encrypted or is not a database +at /home/pi/repos/app-envui/bin/../lib/App/RPi/EnvUI/DB.pm line 66. i +n /home/pi/perl5/perlbrew/perls/perl-5.22.2/lib/site_perl/5.22.2/Danc +er2/Core/App.pm l. 1444 (in cleanup) Can't kill a non-numeric process ID at /home/pi/perl5 +/perlbrew/perls/perl-5.22.2/lib/site_perl/5.22.2/Async/Event/Interval +.pm line 29 during global destruction.

The last line of the error I understand; that's due to the separate proc crashing without waiting for the child proc, I just haven't tidied that up yet.

The crash is occurring on an open DB handle during a basic select statement (at least in this case it was a select).


In reply to [SOLVED]: DBD::SQLite "file is encrypted or is not a database" in running application by stevieb

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.