Edgewall Software

Opened 5 years ago

Closed 4 years ago

#12420 closed defect (fixed)

Safety level may not be changed inside a transaction on SQLite with synchronous=normal if PySqlite 2.8.1 (3.8.2)

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone: 1.0.11
Component: database backend Version: 1.0-stable
Severity: normal Keywords: pysqlite
Cc: Branch:
Release Notes:

Fix raising OperationalError when SQLite with journal_mode and synchronous parameters on pysqlite 2.8.0+.

API Changes:
Internal Changes:


2016-03-28 00:56:58,865 Trac[pool] ERROR: Exception caught on create
Traceback (most recent call last):
  File "/home/jun66j5/src/tracdev/svn/branches/1.0-stable/trac/db/pool.py", line 105, in get_cnx
    cnx = connector.get_connection(**kwargs)
  File "/home/jun66j5/src/tracdev/svn/branches/1.0-stable/trac/db/sqlite_backend.py", line 190, in get_connection
    return SQLiteConnection(path, log, params)
  File "/home/jun66j5/src/tracdev/svn/branches/1.0-stable/trac/db/sqlite_backend.py", line 298, in __init__
    _set_synchronous(cursor, params.get('synchronous'))
  File "/home/jun66j5/src/tracdev/svn/branches/1.0-stable/trac/db/sqlite_backend.py", line 408, in _set_synchronous
    cursor.execute('PRAGMA synchronous = %s' % _quote(value))
OperationalError: Safety level may not be changed inside a transaction
2016-03-28 00:56:58,865 Trac[chrome] ERROR: Error during check of EMAIL_VIEW: TimeoutError: Unable to get database connection within 0 seconds. (OperationalError: Safety level may not be changed inside a transaction)

Attachments (0)

Change History (5)

comment:1 by Jun Omae, 5 years ago

Keywords: pysqlite added

After pysqlite 2.8.0, this issue is reproduced. Also, the same issue is raised with journal_mode=wal parameter.

ERROR: test_insert_empty (trac.db.tests.api.StringsTestCase)
Traceback (most recent call last):
  File "/home/jun66j5/src/tracdev/git/trac/db/tests/api.py", line 311, in setUp
    self.env = EnvironmentStub()
  File "/home/jun66j5/src/tracdev/git/trac/core.py", line 124, in __call__
    self.__init__(*args, **kwargs)
  File "/home/jun66j5/src/tracdev/git/trac/test.py", line 405, in __init__
  File "/home/jun66j5/src/tracdev/git/trac/test.py", line 452, in reset_db
  File "/home/jun66j5/src/tracdev/git/trac/db/api.py", line 253, in init_db
  File "/home/jun66j5/src/tracdev/git/trac/db/sqlite_backend.py", line 212, in init_db
    _set_journal_mode(cursor, params.get('journal_mode'))
  File "/home/jun66j5/src/tracdev/git/trac/db/sqlite_backend.py", line 392, in _set_journal_mode
    cursor.execute('PRAGMA journal_mode = %s' % _quote(value))
OperationalError: cannot change into wal mode from within a transaction

comment:2 by Christian Boos, 4 years ago

Patch (jomae.git@t12420) looks good to me. I tested it on trunk with PySqlite 2.8.1, SQLite 3.12, Python 2.7.10 Windows x64.

  • TRAC_TEST_DB_URL=sqlite:test.db
  • TRAC_TEST_DB_URL=sqlite:test.db?journal_mode=wal
  • TRAC_TEST_DB_URL=sqlite:test.db?journal_mode=wal&synchronous=normal

All tests pass.

comment:3 by Jun Omae, 4 years ago

Owner: set to Jun Omae
Release Notes: modified (diff)
Status: newassigned

Thanks for the reviewing and testing! I'm going to push it.

comment:4 by Jun Omae, 4 years ago

Milestone: next-stable-1.0.x1.0.11

comment:5 by Jun Omae, 4 years ago

Resolution: fixed
Status: assignedclosed

Committed in [14653] and merged to trunk in [14654].

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae to the specified user.

Add Comment

E-mail address and name can be saved in the Preferences .
Note: See TracTickets for help on using tickets.