This is by design.

The read only transaction acquires a "Read" Lock on the database file. 
So if that lock has not been released your writing process will receive the 
SQLITE_LOCKED error code. 

a.  Use a begin exclusive on your writing process and test for sqlite locked. 
Using a loop and retry logic.

The read uncommitted pragma will only work with multi threaded applications not 
multi process so I don't think this will work for you.

The technical reason behind this is that SQLITE does not implement multi 
versioning of its internal pages. If it did this would allow readers and 
writers to co-exist with out locking each other out.



--- On Thu, 7/2/09, Tino Lange <tino.la...@interactivedata.com> wrote:

> From: Tino Lange <tino.la...@interactivedata.com>
> Subject: Re: [sqlite] SQLite3: Database is sometimes locked when a reader is 
> attached with open_v2
> To: sqlite-users@sqlite.org
> Date: Thursday, July 2, 2009, 9:45 AM
> Hi Marcus,
> 
> I have no problem when the reading application gets a lock
> error because the 
> writing application has a lock.
> 
> But the problem is the other way around:
> -> The writing application gets a lock error because
> someone reads!
> 
> This is what I can't understand and what I didn't expect. I
> would expect 
> that the writing application is undisturbed by any readers
> that open with 
> SQLITE_OPEN_READONLY.
> 
> Thanks
> 
> Tino
> 
> ------------------
> 
> 
> Marcus Grimm wrote:
> 
> > I'm afraid this is by design of sqlite: Sqlite will
> lock
> > the database during a writing transaction, I think no
> matter
> > if you open a 2nd connection using the readonly flag.
> > 
> > the typical solutions are:
> > a) retry your read attempt after you receive a busy
> error code until
> >     it proceeds.
> > b) consider shared cache mode and pragma
> read_uncommitted = True;
> > 
> > hope this helps
> > 
> > Marcus
> 
> 
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to