"database is locked" error after upgrading from Trac 1.0.11 to 1.6 (SQLite)

9 views
Skip to first unread message

Maël

unread,
4:37 AM (13 hours ago) 4:37 AM
to Trac Users
Hello,

After upgrading from Trac 1.0.11 to Trac 1.6 with SQLite, I'm encountering this error in logs:

ERROR: Unable to create cache records for revision X in '(default)': OperationalError('database is locked')

Environment:
- SQLite database
- Custom workflow plugin that commits to SVN during ticket transitions
- SVN post-commit hook calls trac-admin changeset added
- PRAGMA busy_timeout = 0 (default)

Root cause:
Trac 1.6 introduced nested transactions in versioncontrol/cache.py:

- sync() opens a transaction (line 182)
- insert_changeset() opens another transaction (line 286)

This creates an inter-process conflict with SQLite:
1. Apache process: ticket transition + SVN commit
2. Post-commit hook: triggers trac-admin changeset added immediately
3. trac-admin process: tries to sync while Apache's transaction is still open
4. → "database is locked"

Trac 1.0.11 passed the transaction as parameter (no nested transactions), so this didn't occur.

Questions:

- Is this a known issue with Trac 1.6 + SQLite + SVN hooks?
- Is there an official workaround for nested transactions in cache.py?

Jun Omae

unread,
9:12 AM (9 hours ago) 9:12 AM
to trac-...@googlegroups.com
Hi,
No known issues.

> - Is there an official workaround for nested transactions in cache.py?

I don't think it is caused by versioncontrol/cache.py. Because Trac
DB-API doesn't support nested transaction. I guess that your custom
workflow plugin has something wrong.

I don't know if effective, "PRAGMA journal_mode WAL" and "PRAGMA
synchronous NORMAL" might help it. The parameters can be set in [trac]
database option like the following:

[trac]
database = sqlite:db/trac.db?journal_mode=wal&synchronous=normal


--
Jun Omae <jun...@gmail.com> (大前 潤)
Reply all
Reply to author
Forward
0 new messages