Repository navigation
fix(config): serialize preferences writes across processes - #255
Draft
shubhamsinnh wants to merge 1 commit into
Draft
shubhamsinnh wants to merge 1 commit into
shubhamsinnh wants to merge 1 commit into
Conversation
Concurrent writers shared preferences.json.tmp and each ran an uncoordinated read-modify-write, so one process could overwrite another process's key or fail to replace the temp file. Hold an exclusive OS lock on preferences.json.lock around the whole read-modify-write in set_default_model, clear_default_model, and set_decisions_route. Keep the sibling temp file and atomic rename, and propagate lock and I/O failures through the existing error path. Validated with 24 concurrent writers across 12 rounds: both independent keys and unrelated content survived, the final document stayed valid JSON, and a direct lock probe blocked the writer until release.
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
This branch has not been deployed
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.
Two Wally processes could overwrite each other’s preference changes or collide on the shared temporary file.
All three preference writers now hold the same OS lock across the whole read-modify-write operation. The file format and atomic replacement stay the same.
Validation: 12 concurrency rounds preserved the expected settings and 4 MiB of unrelated data. A separate lock probe confirmed the writer waited for the lock. Network filesystems were not tested.
CI and formatting pass. The local full suite had 565 passes and two Windows symlink-privilege failures. Strict Clippy reports four pre-existing lints in untouched files.
Summary by cubic
Serializes preferences writes across processes so concurrent writers no longer lose each other's settings or race on the shared temp file.
Takes an exclusive OS lock on
preferences.json.lockaround the whole read-modify-write inset_default_model,clear_default_model, andset_decisions_route. Keeps the sibling temp file and atomic rename; lock and I/O failures propagate through the existing error path with no unlocked fallback.Written for commit 3637c20. Summary will update on new commits.