Hey!
I'm using ActiveRecord with an SQLite Database.
It works great, but has one drawback. SQlite does'nt support multiple connection at one time.
Is there a mathod to synchronize ActiveRecord calls over different threads?
thx CK
Hey!
I'm using ActiveRecord with an SQLite Database.
It works great, but has one drawback. SQlite does'nt support multiple connection at one time.
Is there a mathod to synchronize ActiveRecord calls over different threads?
thx CK
google for activerecord multi threaded I think it has something to do with allow_concurrency. -R
Roger Pack wrote:
google for activerecord multi threaded I think it has something to do with allow_concurrency. -R
On Mon, May 5, 2008 at 6:47 AM, Christian Kerth
Hmmm doesn't work form me. I still get a "busy-Exception".
Other options?
thx
allow_concurrency "allows conconcurrency" on the connection (as opposed to the database), so 2 threads can execute on the same connection. If you're trying to have 2 applications read from the same database (like having a script/runner do database stuff in the background while your server runs), this is simply not possible. Because SQLite effectively uses a flat-file, there is no way to have more than 1 connection to the same database -- there is no way for one connection to know what the other is doing so as to avoid concurrent modifications resulting in data corruption.
tekwiz wrote:
allow_concurrency "allows conconcurrency" on the connection (as opposed to the database), so 2 threads can execute on the same connection. If you're trying to have 2 applications read from the same database (like having a script/runner do database stuff in the background while your server runs), this is simply not possible. Because SQLite effectively uses a flat-file, there is no way to have more than 1 connection to the same database -- there is no way for one connection to know what the other is doing so as to avoid concurrent modifications resulting in data corruption.
i would need a queuing mechanism, that executes queries fifo.
Wouldn't it be possible to achieve such a behaviour with a mutex, that synchronizes access to activerecord's save and destroy methods?
ck
Not if you're talking about separate mongrels (or rails instance of any sort). But doesn't sqlite allow enough concurrency (File Locking And Concurrency In SQLite Version 3) ?
Fred
Frederick Cheung wrote:
Yes, your fifo/mutex concept is correct. You just have to ensure that 2 active record instances don't attempt to play with the database at the same time.
You are correct that SQLite3 does provide "enough" concurrency; however, the active record decides to pitch a hissy-fit, throwing exceptions, when it encounters a locked db rather than waiting and trying again for a certain period.