Skip to content

Conversation

@psarna
Copy link
Contributor

@psarna psarna commented Oct 29, 2022

We want to be able to use WAL journaling from the browser eventually, so the flag is hereby dropped.

Draft, because it only makes sense to drop this commit after thoroughly checking that WAL can be enabled in the fiddle application and work just fine (and I didn't manage to do that with this change alone).

We want to be able to use WAL journaling from the browser
eventually, so the flag is hereby dropped.
@psarna psarna marked this pull request as ready for review October 30, 2022 16:59
@psarna psarna requested a review from penberg October 30, 2022 16:59
@psarna
Copy link
Contributor Author

psarna commented Oct 30, 2022

Alright, I verified it's fine to compile-in WAL. The reason it does not work out-of-the-box now is that WAL is only enabled if libsql detects that it's supported, which is currently done via the following heuristics:

  1. if we're in exclusive mode, WAL is supported, because we don't need shared memory
  2. otherwise, WAL is supported iff VFS supports shared memory, for locking purposes

This heuristics will not be sufficient for us once #53 comes in, because it would be up to the WAL implementation whether it needs locks or not. So, as a workaround for playing with the fiddle app, it's enough to simply turn on exclusive mode in order to enable WAL:

.open file:name?vfs=opfs
PRAGMA main.locking_mode=exclusive;
PRAGMA journal_mode=wal; -- it works!
CREATE TABLE IF NOT EXISTS t1(id);
INSERT INTO t1(id) VALUES (42);
INSERT INTO t1(id) VALUES (43);
SELECT * FROM t1;

@psarna psarna mentioned this pull request Oct 30, 2022
@penberg penberg merged commit 15e8f52 into tursodatabase:main Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants