Thank you so much!
That apparently was the problem after a few quick tests. I updated my test script to the below (each fork() creates its own db handle), and letting it run for ~5 minutes, there are no issues. I'll apply similar logic to my real app and see how it goes, then I'll mark this thread solved if the problem vanishes.
I was looking in all the wrong places for information. I should have done more than just skimmed the docs. sigh.
use warnings; use strict; use Parallel::ForkManager; use DBI; my $db_file = 'test.db'; my $dbh = DBI->connect( "dbi:SQLite:dbname=$db_file", "", "", {RaiseError => 1} ) or die $DBI::errstr; my $pm = Parallel::ForkManager->new(20); for (1..2){ $pm->start and next; my $interval = $_ / 5; my $dbh = DBI->connect( "dbi:SQLite:dbname=$db_file", "", "", {RaiseError => 1} ) or die $DBI::errstr; while (1){ dbwrite($dbh, $interval); #sleep 1; } } while(1){ my $sth = $dbh->prepare( "SELECT * FROM test WHERE id=?;" ); $sth->execute('test'); my $val = $sth->fetchrow_hashref()->{value}; print "$val\n"; } sub dbwrite { my ($dbh, $interval) = @_; my $sth = $dbh->prepare( 'UPDATE test SET value=? WHERE id="test";' ); $sth->execute($interval); };
update: I did trigger the below error after some time, but that's a different problem that it appears as though there are built-in workarounds for that I'll play with (mind you, it's probably triggered because we're write/read to the db at full speed):
DBD::SQLite::st execute failed: database is locked at pm.pl line 49.
/update
In reply to Re^3: DBD::SQLite "file is encrypted or is not a database" in running application (repro code)
by stevieb
in thread [SOLVED]: DBD::SQLite "file is encrypted or is not a database" in running application
by stevieb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |