Replace in-process mutex with cross-process file locking for FileStore #357
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.
Summary for Reviewers
This PR refactors the EncryptedFileStore to improve reliability and fix potential data loss issues during concurrent access across multiple processes.
Key Changes
File locking mechanism replaced: Switched from async-mutex (in-process only) to proper-lockfile (cross-process file locking) to properly handle concurrent access from multiple language server instances.
Eager file creation on startup: The store now creates encrypted files immediately on construction rather than lazily on first write. This ensures the lock file target exists before any operations.
Corrupted file recovery: Added automatic recovery when decryption fails - the store recreates itself with empty content instead of crashing.
Store initialization moved to factory constructor: FileStoreFactory now pre-creates all stores at startup with a configurable list of store names, and get() throws if requesting an unknown store (fail-fast behavior).
Simplified content management: Removed nullable content field - it's now always initialized. Each write operation re-reads the file under lock to ensure it has the latest data from other processes.
Replaced error stack parsing with simply adding the full stack (since these are not metric dimensions anymore)