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

Fix Pos() deadlock with file system invalidation #206

Merged
merged 1 commit into from Nov 29, 2022
Merged

Conversation

benbjohnson
Copy link
Collaborator

This pull request fixes a deadlock that occurs between litefs.DB.mu and the FUSE file system invalidation. Currently, the FUSE library is set to be synchronous so holding the litefs.DB.mu lock while committing to the journal and reading the -pos file can cause a deadlock.

The fix is to remove the sync.Mutex from litefs.DB as it was no longer necessary because SQLite obtains locks for all the calls inside that alter data. The litefs.DB.pos field has been converted to an atomic.Value so that its value can be obtained independently of the SQLite locks. This is useful as a write transaction on the rollback journal would prevent inspection of the position.

Originally reported by @kentcdodds in this Fly.io community forum post: https://community.fly.io/t/site-falls-over-every-few-hours-before-rebooting/8907/37

@benbjohnson benbjohnson added this to the v0.3.0 milestone Nov 29, 2022
@benbjohnson benbjohnson merged commit 43de126 into main Nov 29, 2022
@benbjohnson benbjohnson deleted the fix-pos-deadlock branch November 29, 2022 20:41
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.

None yet

1 participant