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

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.