Repository navigation
Conversation
A permission create loaded the user file, then saved it outside the per-file lock, so users created meanwhile vanished.
authenticate() saved the user list it loaded before hashing, so users created during a login's hash upgrade vanished.
put, delete and destroy saved a list they had loaded earlier, so rows created in between vanished. They now change rows inside mutate(), which skips the write when the callback returns false. Nothing writes outside the lock, so save() and the _save helpers are gone. A file without last_id now records its highest id before a change, so destroying that row can't free its id for reuse. A permission with no user or group fails on the file stores instead of storing nothing: inline permission ids are user and group ids, so there is no free id.
A load during a write could read half a file and fail to parse. _write now writes a copy with the old file's mode and renames it over the file.
aberoham
force-pushed
the
file-store-atomic-writes
branch
from
October 14, 2026 21:11
1642410 to
825fe1a
Compare
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on #70. Until #70 merges, the diff also shows its commits. The change here is the last commit,
store: write file stores atomically.The json and toml stores rewrite a whole file on every write.
fs.writeFiletruncates it first, so a load in the same api process can read half a file during a write. A json load then throws "Unexpected end of JSON input". A toml load can parse the half as fewer rows.A write now goes to a temporary file beside the real one, with the old file's mode, and is renamed into place. A load sees either the old file or the new one. The store directory must be writable, not just its files.
A probe ran loads through repeated writes of 20,000 rows. Before this change, 319 of 482 json loads and 305 of 478 toml loads failed or came back short. None did after it.