"Sabyasachi Ruj" <[EMAIL PROTECTED]>
wrote in message
news:[EMAIL PROTECTED]
> Now, I have two threads:-
> Thread1: Is deleting 7,00, 000 rows from the table.
> Thread2: Is doing SELECT on the same table.
>
> Now the problem is sometimes the sqlite3_prepare for the SELECT query
> is failing with SQLITE_BUSY error.

Are you sure it's the prepare that fails, and not step? Only the very 
first prepare after opening the connection may fail this way, because 
SQLite needs to read database schema at this point.

> 1. What is the best way to handle this error, and continue working
> normally?

Retry until you manage to go through. Or, prepare all the necessary 
statements up front, before commencing any database work. Then prepare 
won't fail (of course, step still may).

> 2. Is there any documentation in sqlite3.org, which discuses the
> locking mechanism for DELETEs? Exacly in what phase of DELETE sqlite
> creates the exclusive lock, so, the SELECT is failing?

http://sqlite.org/lockingv3.html

EXCLUSIVE lock is obtained whenever SQLite needs to write to the 
database file. This may happen when the transaction is committed, or 
when the number of changes in a still-open transaction becomes so large 
that it no longer fits in a memory cache and has to be spilled to disk.

Igor Tandetnik



_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to