Skip to content

fix(config): serialize preferences writes across processes - #255

Draft
shubhamsinnh wants to merge 1 commit into
RunanywhereAI:mainfrom
shubhamsinnh:fix/preferences-transactions
Draft

shubhamsinnh wants to merge 1 commit into
RunanywhereAI:mainfrom
shubhamsinnh:fix/preferences-transactions

Conversation

@shubhamsinnh

@shubhamsinnh shubhamsinnh commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

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.lock around the whole read-modify-write in set_default_model, clear_default_model, and set_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.

View guided diff

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.
@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

This branch has not been deployed

No deployments
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