Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use WAL by default #169

Closed
lemon24 opened this issue Jun 15, 2020 · 3 comments
Closed

Use WAL by default #169

lemon24 opened this issue Jun 15, 2020 · 3 comments

Comments

@lemon24
Copy link
Owner

lemon24 commented Jun 15, 2020

https://www.sqlite.org/wal.html

This is mainly to improve concurrency (although using a SQLite with HAVE_USLEEP would yield better results; TODO: mention this somewhere in the code).

It should be possible to turn it off via a storage argument (pending #168) for backwards compatibility.

@lemon24
Copy link
Owner Author

lemon24 commented Jun 28, 2020

This shows that enabling WAL greatly reduces "database is locked" errors: #175 (comment).

lemon24 added a commit that referenced this issue Jun 29, 2020
@lemon24
Copy link
Owner Author

lemon24 commented Jun 30, 2020

The PyPy tests are failing:

_sqlite3.OperationalError: cannot commit transaction - SQL statements in progress

This is most likely because PRAGMA journal_mode=... in create_db() gets run within a transaction. I am not sure why there's a difference in behavior between the PyPy and CPython bindings.

Regardless, the CLI shows that enabling WAL is not supported within a transaction:

sqlite> pragma journal_mode;
delete
sqlite> begin;
sqlite> create table u(a);
sqlite> pragma journal_mode=wal;
delete
sqlite> commit;
sqlite> pragma journal_mode;
delete
sqlite> begin;
sqlite> pragma journal_mode=wal;
Error: cannot change into wal mode from within a transaction
sqlite> commit;

I am also not sure why we don't get the same error in Python.

lemon24 added a commit that referenced this issue Jun 30, 2020
This reverts commit df58732.

For #169.
lemon24 added a commit that referenced this issue Jun 30, 2020
@lemon24
Copy link
Owner Author

lemon24 commented Jun 30, 2020

So, turns out the "cannot commit transaction - SQL statements in progress" PyPy error is because we should be explicitly closing cursors, and not relying on the GC to do so for us: https://bitbucket.org/pypy/pypy/issues/3080/sql-connection-error-cannot-commit

In order to fix this regression, we need to at least explicitly close the cursors up to the PRAGMA statement (ideally, we should do all of them, but there's a lot).

lemon24 added a commit that referenced this issue Jun 30, 2020
@lemon24 lemon24 closed this as completed Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant