Fix bd-306: Use PID suffix for temp files to avoid concurrent collisions

- Change temp filename from issues.jsonl.tmp to issues.jsonl.tmp.<pid>
- Prevents race conditions when multiple bd commands run concurrently
- Added issues bd-300 through bd-306 (git-based restoration epic)
This commit is contained in:
Steve Yegge
2025-10-16 14:54:12 -07:00
parent 5bfecf85f0
commit 2c134e237b
2 changed files with 270 additions and 282 deletions

View File

@@ -634,7 +634,8 @@ func flushToJSONL() {
})
// Write to temp file first, then rename (atomic)
tempPath := jsonlPath + ".tmp"
// Use PID in filename to avoid collisions between concurrent bd commands (bd-306)
tempPath := fmt.Sprintf("%s.tmp.%d", jsonlPath, os.Getpid())
f, err := os.Create(tempPath)
if err != nil {
recordFailure(fmt.Errorf("failed to create temp file: %w", err))