On Jul 24, 2006, at 11:47, Xavier Noria wrote:
I am trying to understand a crash I get very often. There are two
processes accessing to the same database in a Windows XP (through
Active Record) doing simple CRUDs on tables, and from any of the
two at random I get an SQLite3::BusyException, for example (copied
by hand):
SQLite3::BusyException: database is locked: SELECT count(*) AS
count_all ...
The processes use transactions, but my understanding is that if the
database is locked the other one will wait to do its stuff until it
is released. Is that right? If so, all of this is quite quick, is
there any tiny timeout that raises the exception if the lock is not
acquired? Os does it sound like an adapter issue to you?
Just for the archives, the problem is fixed.
Precisely, by default the SQLite adapter does nothing special with
SQLITE_BUSY and provides hooks busy_handler and busy_timeout. Michael
Meckler gave this solution in the Rails mailing list, which is tu
subclass the main persitence class to configure that stuff per
connection:
class RetryModel < ActiveRecord::Base
self.abstract_class = true
self.connection.raw_connection.busy_timeout(2000) if
self.connection.adapter_name == 'SQLite'
end
and make all persistence models be children of that one.
-- fxn