Comment 1 for bug 136771

Revision history for this message
Richard Boulton (richardboulton) wrote :

After looking into the state in which the database is left after a commit() fails more closely, I believe that the connection is only left in a state in which COMMIT can be retried if the failure was due to the database being locked. In all other cases, the transaction is rolled back, and the connection is no longer in the middle of a transaction. My proposed fix assumed that any failure left the transaction open.

According to http://www.sqlite.org/lang_transaction.html the "database locked" case can be detected by the SQLITE_BUSY return code. pysqlite2 converts this to the "database is locked" OperationalError, and after reading through the code, I believe no other case will have this message. Therefore, we can detect this case, and set the SQLiteConnection._in_transaction member to False in all other cases.

I've pushed changes to implement this to the sqlite-locked-recovery branch.