Skip to content

Move WAL commit to after WAL_WRITE_LOCK release#205

Merged
benbjohnson merged 1 commit intomainfrom
fix-wal-commit
Nov 29, 2022
Merged

Move WAL commit to after WAL_WRITE_LOCK release#205
benbjohnson merged 1 commit intomainfrom
fix-wal-commit

Conversation

@benbjohnson
Copy link
Collaborator

This pull request fixes a bug where the WAL segment is computed before the transaction fully completes. This can occur because SQLite can rewrite sections of the WAL as needed and then rewrites frame headers at the end. This can cause the database & the LTX files to become out of sync and cause checksum mismatch errors.

LiteFS now waits for WAL_WRITE_LOCK to be released before computing the transaction's pages. This ensures that the final version of the frames are written before determining the transaction boundaries.

@benbjohnson benbjohnson added this to the v0.3.0 milestone Nov 29, 2022
@benbjohnson benbjohnson merged commit a66fc96 into main Nov 29, 2022
@benbjohnson benbjohnson deleted the fix-wal-commit branch November 29, 2022 18:51
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.

1 participant