anki-sync-server
anki-sync-server copied to clipboard
OperationalError: cannot change out of wal mode from within a transaction
There is a particular user who gets this error any time they sync:
Traceback (most recent call last):
File "/opt/anki_server/src/anki-sync-server/AnkiServer/threading.py", line 95, in _run
ret = self.wrapper.execute(func, args, kw, return_queue)
File "/opt/anki_server/src/anki-sync-server/AnkiServer/collection.py", line 58, in execute
ret = func(*args, **kw)
File "/opt/anki_server/src/anki-sync-server/AnkiServer/threading.py", line 145, in _close
self.wrapper.close()
File "/opt/anki_server/src/anki-sync-server/AnkiServer/collection.py", line 105, in close
self.__col.close()
File "/usr/share/anki/anki/collection.py", line 140, in close
self.db.execute("pragma journal_mode = delete")
File "/usr/share/anki/anki/db.py", line 35, in execute
res = self._db.execute(sql, a)
OperationalError: cannot change out of wal mode from within a transaction
I don't know what in particular is up with their collection that this happens - I'll attempt to determine that. However, this error occurs when the Anki Server is attempting to close the collection - which means it never gets closed and the server keeps trying over and over again. In fact, the only way to stop it, is to restart the server!
So, even if I don't figure out what's causing this, I need to at least change the close code to make sure it gets closed (even if it's forced!) so that we don't have an infinite loop.
I have the same problem since the update to 2.1.0a10:
An error occurred. It may have been caused by a harmless bug,
or your deck may have a problem.
To confirm it's not a problem with your deck, please run Tools > Check Database.
If that doesn't fix the problem, please copy the following
into a bug report:
Caught exception:
File "/usr/share/anki/aqt/sync.py", line 346, in run
self.col.close(save=False)
File "/usr/share/anki/anki/collection.py", line 156, in close
self.db.execute("pragma journal_mode = delete")
File "/usr/share/anki/anki/db.py", line 31, in execute
res = self._db.execute(sql, a)
<class 'sqlite3.OperationalError'>: cannot change out of wal mode from within a transaction
Check database doesn't reveal any problem.
Exactly the same error as published by @joelthelion. The version is 2.1.0a10, ArchLinux 32-bit.
Also using Arch (64 bit)
It's already fixed, see #59.