Description
If two processes start simultaneously and both decide to migrate usage.json, the second renameSync raises EEXIST and the fallback copy-overwrites the freshly-renamed file. The user data ends up being whatever the second process wrote.
Environment
- OS: Any
- Node version: v22.20.0
- Nanocoder version: 1.30.0
- Provider: N/A
- Model: N/A
Steps to Reproduce
- Trigger a legacy usage migration from two concurrent instances.
Expected Behavior
Needs a rename no-clobber or fsync-and-swap pattern to handle the migration safely.
Actual Behavior
The second process overwrites the file, potentially causing data loss.
Additional Context
Description
If two processes start simultaneously and both decide to migrate
usage.json, the secondrenameSyncraisesEEXISTand the fallback copy-overwrites the freshly-renamed file. The user data ends up being whatever the second process wrote.Environment
Steps to Reproduce
Expected Behavior
Needs a rename no-clobber or fsync-and-swap pattern to handle the migration safely.
Actual Behavior
The second process overwrites the file, potentially causing data loss.
Additional Context