Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(state): Add file locking to auth cache#1793

Merged
gtema merged 1 commit into
mainfrom
lock
Jun 15, 2026
Merged

feat(state): Add file locking to auth cache#1793
gtema merged 1 commit into
mainfrom
lock

Conversation

@gtema

@gtema gtema commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Add exclusive/shared file locking to the auth cache read-modify-write
cycle to prevent data loss from concurrent writers. Uses a dedicated
.lock file so the lock survives NamedTempFile::persist replacing the
data file.

  • Use std::fs::File::lock()/lock_shared() (stabilized in Rust 1.89)
  • Separate lock file (.lock extension) per auth hash
  • Shared lock on reads, exclusive lock on writes
  • Lock acquisition failures are tolerated (best-effort cache)
  • Atomic write via NamedTempFile::persist with fallback to direct write
  • Add 9 unit tests covering save/load, corruption, clear, concurrent
    writes
  • Update MSRV to 1.89 (required for File::lock API)
  • Remove skip_serializing_if from Project/Domain for postcard
    compatibility
  • Move tempfile from dev-dependencies to dependencies (used in prod
    code)

Comment thread sdk/core/src/state.rs Fixed
Comment thread sdk/core/src/state.rs Fixed
Comment thread sdk/core/src/state.rs Fixed
Comment thread sdk/core/src/state.rs Fixed
Add exclusive/shared file locking to the auth cache read-modify-write
cycle to prevent data loss from concurrent writers. Uses a dedicated
.lock file so the lock survives NamedTempFile::persist replacing the
data file.

- Use std::fs::File::lock()/lock_shared() (stabilized in Rust 1.89)
- Separate lock file (.lock extension) per auth hash
- Shared lock on reads, exclusive lock on writes
- Lock acquisition failures are tolerated (best-effort cache)
- Atomic write via NamedTempFile::persist with fallback to direct write
- Add 9 unit tests covering save/load, corruption, clear, concurrent
  writes
- Update MSRV to 1.89 (required for File::lock API)
- Remove skip_serializing_if from Project/Domain for postcard
  compatibility
- Move tempfile from dev-dependencies to dependencies (used in prod
  code)
@gtema gtema merged commit fe94295 into main Jun 15, 2026
24 checks passed
@gtema-release-plz gtema-release-plz Bot mentioned this pull request Jun 12, 2026
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.

2 participants