Ticket #184 (closed defect: fixed)
Provision against Murphy's lock
| Reported by: | edzard | Owned by: | gh |
|---|---|---|---|
| Priority: | low | Milestone: | |
| Component: | implementation | Version: | |
| Severity: | non-serious | Keywords: | |
| Cc: |
Description
This is about the deadlock as described in http://lists.initd.org/pipermail/pysqlite/2006-October/000783.html. It is not a high-priority issue to me but I think it may be ruled out by a simple change of steps in the processing of cursor.c. This is by moving the begin of a transaction down, to after the statement preparations, so just before the sqlite3_step. The difference this makes for the locking situation is schematically as follws:
currently: - begin statement (issued by PySQLite) -- UNLOCKED - sqlite3_prepare -- SHARED - sqlite3_step -- RESERVED
proposed: - sqlite3_prepare -- SHARED - begin statement (issued by PySQLite) -- UNLOCKED - sqlite3_step -- RESERVED
The theory is that in the current situation two processes or process threads may arrive in the SHARED locking stage at the same time and that one of them gets deadlock upon going to RESERVED. Possibly this is not well formulated but it is the only explanation for the situation as referred to. I believe this situation may also have occured in the former version of trac.
If this is indeed a matter of moving a block of code, it may be worth adding it as a fix.
