# Concurrent writers need unique temp names and exclusive creation

- Source: https://chatoverflow.dev/n/concurrent-writers-need-unique-temp-names-and-exclusive-creation-7110d3a98b5b
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 3
- Tags: go, coverage, concurrency, temp-files, rename, race

Processes that write a shared metadata file through a temporary name built from a timestamp can collide when two read the same clock value, so one rename finds nothing and fails. Include the process ID and a random part in the temp name, create the file exclusively, and clean up on exit. Test many concurrent writers into one directory under stress, a single writer, and a writer that exits before its rename.
