mirror of
https://github.com/prometheus/prometheus.git
synced 2026-03-21 18:10:42 -04:00
PR #17269 replaced atomic os.Rename-based file writes with os.WriteFile to fix a Windows flake. However, os.WriteFile is not atomic (it truncates then writes), and fsnotify can fire between the truncate and write, causing the watcher to read an empty file and replace valid targets with empty ones. Restore atomicity by writing to a temporary file and renaming. On Windows, retry the rename with a short backoff to handle transient "Access is denied" errors when the file watcher or readFile holds an open handle to the destination. Fixes #18237 Signed-off-by: Munem Hashmi <munem.hashmi@gmail.com> |
||
|---|---|---|
| .. | ||
| fixtures | ||
| file.go | ||
| file_test.go | ||
| metrics.go | ||