On Mon, Jun 13, 2011 at 12:40:14PM +0200, Jean-Christophe Deschamps scratched 
on the wall:
> 
> >As was being discussed yesterday, I have four processes accessing the
> >same database file.  When they perform an sqlite action, I wish them to
> >block if the DB is not available.  SQLite does not block if it finds the
> >db busy or locked, it returns an error code.
> 
> You can have SQLite do all this by itself, I mean without any extra 
> code.  I've found this is the easiest way to handle the situation.
> 
> Invoke sqlite3_busy_timeout() with a safe timeout for every connection 
> to the DB.
> Use IMMEDIATE transactions everywhere.
> 
> That's all you have to do.

  Well, yes and no.  You still have to deal with the case of
  SQLITE_BUSY being returned due to deadlocks.  Setting a timeout and
  using BEGIN IMMEDIATE will help significantly, but not completely
  eliminate this issue.  It also means that if an SQLITE_BUSY does slip
  through, you have no choice but to rollback the transaction and start
  all over.

  For more specifics, see:

  http://sqlite.org/lockingv3.html
  http://sqlite.org/c3ref/busy_handler.html   <= deadlock info
  http://sqlite.org/c3ref/busy_timeout.html


   -j

-- 
Jay A. Kreibich < J A Y  @  K R E I B I.C H >

"Intelligence is like underwear: it is important that you have it,
 but showing it to the wrong people has the tendency to make them
 feel uncomfortable." -- Angela Johnson
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to