[New-bugs-announce] [issue26625] SELECT-initiated transactions can cause "database is locked" in sqlite

Rian Hunter report at bugs.python.org
Wed Mar 23 12:28:34 EDT 2016


New submission from Rian Hunter:

When a transaction starts with a SELECT statement this can invoke a "database is locked" error if the SELECT statement is not exhausted or explicitly closed.

This can lead to subtle "database is locked" bugs, even when a large timeout is set on the connection. Many, many people are affected by this bug (search the web for "python sqlite database is locked").

The attached code demonstrates this bug and possible (unintuitive) fixes. The best workaround is to "explicitly" start a transaction in these cases by issuing a dummy DML statement. This seems very clumsy.

My proposed fix is to implicitly open a transaction before all non-DDL statements (including SELECT statements), not just DML statements.

If there won't be a fix soon, then at least the documentation should note this quirky behavior.

----------
components: Library (Lib)
files: unintuitive_sqlite_behavior.py
messages: 262282
nosy: rhunter
priority: normal
severity: normal
status: open
title: SELECT-initiated transactions can cause "database is locked" in sqlite
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file42259/unintuitive_sqlite_behavior.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26625>
_______________________________________


More information about the New-bugs-announce mailing list