Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if errors.Is(err, os.ErrExist) { | ||
| time.Sleep(50 * time.Millisecond) | ||
| info, statErr := os.Stat(s.lockPath) | ||
| if statErr == nil { | ||
| if time.Since(info.ModTime()) > lockStaleAgeThreshold { | ||
| if removeErr := os.Remove(s.lockPath); removeErr == nil { | ||
| continue | ||
| } |
There was a problem hiding this comment.
Removing stale lock purely by age can free an active writer
The new stale-lock handling deletes the lock file whenever its ModTime exceeds lockStaleAgeThreshold, without checking the PID written into the file. If a legitimate save operation holds the lock for more than 30 seconds (e.g. slow disk, a large file, or the process is paused), a concurrent call will consider the lock stale, delete the file, and enter the critical section while the first writer is still updating the store. This reintroduces the concurrent write corruption that the locking mechanism is meant to prevent. The stale check should verify that the recorded PID is no longer running (or otherwise ensure the lock is truly abandoned) before removing it, or avoid expiring active locks by age alone.
Useful? React with 👍 / 👎.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68f7e94c32dc832cb9683156aa138095