stevieb has asked for the wisdom of the Perl Monks concerning the following question:
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).
|
|---|