I have a Perl program that we have run successfully every day for almost the past 2 years, but which crashes today with the error message:
FATAL ERR: Can't do PRAGMA cache_size = 1000000: attempt to write a readonly database
The SQLite database in question is readonly, and always has been, and the code has always used PRAGMA cache_size = 1000000
on it immediately after opening its readonly connection.
Setting cache_size is not a write operation, and does not fail if I access the db directly thru the DBI, like this:
$dbh->do("PRAGMA cache_size = 1000000")
However, the code makes SqliteH::db a subclass of DBI::db, then calls this function from the subclass:
$self->SUPER::do("PRAGMA cache_size = 1000000")
and it now dies with "DBD::SQLite::db do failed: attempt to write a readonly database at /local/ifs_projects/prok/function/src/lib/SqliteH.pm line 329."
The code worked with CentOS 5, Perl 5.10.1, DBD::SQLite 1.29, and DBI 1.611. It does not work CentOS 6, Perl 5.16, DBD::SQLite 1.39, and DBI 1.627. I am however mystified that it /did/ work last week on CentOS 6 and Perl 5.16. IT may have upgraded DBD::SQLite or DBI over the weekend.
Please do not change the title to "Suddenly getting error on program that has worked for months" again. That is an unhelpful and nonspecific title.