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

Broken WAL mode in 1.3.0|1 #39

Closed
LarsKloseV opened this issue May 5, 2021 · 7 comments
Closed

Broken WAL mode in 1.3.0|1 #39

LarsKloseV opened this issue May 5, 2021 · 7 comments

Comments

@LarsKloseV
Copy link

I was actually trying to replace sqlite3mc 1.1.1 with 1.3.1 using WAL mode and some old database, but stumbled upon some issues. After narrowing down I found that WAL mode in general seems to be broken in release 1.3.1 (or 1.3.0).
Run this to create a new database (in the sqlite3mc shell provided in the binary download for win64):

.open newtest-wal1.db
pragma cipher=chacha20;
pragma key='123';
pragma journal_mode=wal;
create table test (x int);
begin immediate;
insert into test (x) values (1);
commit;
select * from test;

and you still get a result, but after re-opening the database again:

.open
.open newtest-wal1.db
pragma cipher=chacha20;
pragma key='123';
select * from test;

we're lost with a broken db:
Error: unsupported file format

My original attempt was to model our application code and switch back out of WAL mode before closing the db:

.open
.open newtest-wal2.db
pragma cipher=chacha20;
pragma key='123';
pragma journal_mode=wal;
create table test (x int);
begin immediate;
insert into test (x) values (1);
commit;
select * from test;
pragma journal_mode=delete;

which also fails, but with a different error message:
Error: database disk image is malformed

@utelle
Copy link
Owner

utelle commented May 5, 2021

Unfortunately I have to confirm the issue. Thanks for reporting. I will look into it to find out the cause of the problem.

utelle added a commit that referenced this issue May 6, 2021
On writing pages to a WAL journal encryption was not enabled due to referencing the wrong codec pointer. This corrupted the WAL journal.
@utelle
Copy link
Owner

utelle commented May 6, 2021

I think I found the cause of the problem and hopefully fixed it with commit 43bd436.

On writing the WAL journal file the codec pointer was not determined correctly leading to a corrupted WAL journal. A small, but fatal mistake. I'm sorry for the inconveniences this may have caused.

Please verify that it now works for you. When I get a confirmation from you I will make a new release.

@LarsKloseV
Copy link
Author

I will let you know. Will take a little time because I want to make sure it also works in some other scenario I had problems with in 1.1.1

@utelle
Copy link
Owner

utelle commented May 6, 2021

Take your time. Thanks for testing in real world scenarios.

@LarsKloseV
Copy link
Author

The point in case here seems to be fixed as you expected.
However I found another, probably unrelated issue, see #40. If (as I sincerely hope) there's a fix for that, too, I'd rather wait for a new release a bit more.

@utelle
Copy link
Owner

utelle commented May 6, 2021

The point in case here seems to be fixed as you expected.

I'm pretty confident that WAL journal mode now works as expected.

However I found another, probably unrelated issue, see #40. If (as I sincerely hope) there's a fix for that, too, I'd rather wait for a new release a bit more.

Yes, that's understandable. And it is now more important to get things right than to publish just another broken release. I added a note to the release messages of version 1.3.0 and 1.3.1 that WAL journal mode is broken in those releases. Users of the default Rollback Journal mode are not affected.

utelle added a commit that referenced this issue May 14, 2021
@utelle
Copy link
Owner

utelle commented May 18, 2021

Release 1.3.2 fixes the underlying problems and provides a configuration parameter to facilitate the transition from prior versions. The documentation has been updated accordingly. Therefore this issue will be closed. Reopen it if necessary.

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

No branches or pull requests

2 participants