-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 02/19/2011 09:25 PM, Frank Chang wrote:
> 
>    I wanted to thank Roger Binns for solving my problem. 

You are welcome :-)

> I was able to determine the sqlite database was corrupted 

Just to be clear for people finding this thread in the future, your database
was not corrupt.  Getting a corrupt SQLite database is a *very* serious
problem and is something that should not happen.

Your actual problem was that you could not complete a transaction due to
locking and concurrency.

> Evidently, the use of BEGIN EXCLUSIVE prevents my transaction from being
interrupted by another connection from the same process.

See this, in particular section 3:

   http://www.sqlite.org/lockingv3.html

Merely starting a transaction with BEGIN does not acquire an exclusive lock
since you may not even do a write.  SQLite tries to keep the database
exclusively locked for as short a period of time as possible.  However once
you do start writing then it will need to get an exclusive lock which can
fail if someone else has it.  Using BEGIN EXCLUSIVE then moves that lock
acquisition to the BEGIN statement which means you can't fail later on since
you already have it.

In any event if you are going to have concurrent activity, especially
writing then it is important to understand SQLite's concurrency model as in
the document above.

You may also have been able to solve the issue by using a busy timeout.

If you will have a lot of concurrent reading and writing then WAL mode
introduced in 3.7 may be a better fit:

 http://www.sqlite.org/wal.html

Roger
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk1gwN0ACgkQmOOfHg372QSDhQCfQ1zDm35KHLixA/9NnBXm2Iak
JdQAn1Fxnyko5GP56wdZ5ACjXIpUasDV
=EX+O
-----END PGP SIGNATURE-----
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to