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

Improve Wal locking on BSD #203

Closed
ncruces opened this issue Dec 14, 2024 · 0 comments · Fixed by #204
Closed

Improve Wal locking on BSD #203

ncruces opened this issue Dec 14, 2024 · 0 comments · Fixed by #204
Assignees
Labels
enhancement New feature or request

Comments

@ncruces
Copy link
Owner

ncruces commented Dec 14, 2024

For Litestream to work on BSD, there's no alternative but to use POSIX advisory locks on the Wal index.

Locking the entire file with flock, as we're currently doing, is “failsafe“ (no corruption can result from it), but it violates the SQLite locking protocol.

Fortunately, although POSIX locks are awful, we already only keep a single file descriptor to the Wal index file which fixes most issues with them. Instead of opening, and stating for SameFile we can stat and open (which introduces a race, but there's no way around that).

We're also already assuming we must open the Wal index read/write on BSD, which makes things easier.

And Implementing xShmLock with a mix of POSIX and memory locks is also much easier that xLock.

I still hate POSIX locks, but maybe it's not so bad for this, and it should improve things significantly.

This should make it so that Litestream works on BSD, which superseriousbusiness/gotosocial#1753 really wants.

@ncruces ncruces added the enhancement New feature or request label Dec 14, 2024
@ncruces ncruces self-assigned this Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant