{"record":{"id":"b13c0aa0491cbdce","repo":"thanos-io/thanos","slug":"rename-file","errorCode":null,"errorMessage":"rename file","messagePattern":"rename file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/reloader/reloader.go","lineNumber":394,"sourceCode":"\t\tif err != nil {\n\t\t\treturn errors.Wrap(err, \"read compressed config file\")\n\t\t}\n\t}\n\n\tb, err = r.expandEnv(b)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"expand environment variables\")\n\t}\n\n\ttmpFile := outputFile + \".tmp\"\n\tdefer func() {\n\t\t_ = os.Remove(tmpFile)\n\t}()\n\tif err := os.WriteFile(tmpFile, b, 0644); err != nil {\n\t\treturn errors.Wrap(err, \"write file\")\n\t}\n\tif err := os.Rename(tmpFile, outputFile); err != nil {\n\t\treturn errors.Wrap(err, \"rename file\")\n\t}\n\treturn nil\n}\n\n// apply triggers Prometheus reload if rules or config changed. If cfgOutputFile is set, we also\n// expand env vars into config file before reloading.\n// Reload is retried in retryInterval until watchInterval.\nfunc (r *Reloader) apply(ctx context.Context) error {\n\tvar (\n\t\tcfgHash         []byte\n\t\twatchedDirsHash []byte\n\t)\n\n\tif r.cfgFile != \"\" {\n\t\th := sha256.New()\n\t\tif err := hashFile(h, r.cfgFile); err != nil {\n\t\t\treturn errors.Wrap(err, \"hash file\")\n\t\t}","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/reloader/reloader.go#L376-L412","documentation":"Wraps os.Rename in Reloader.normalize: the atomically-staged .tmp file could not be renamed over the output file (cross-device link, target locked). The deferred cleanup removes the orphaned temp file and the reload attempt fails.","triggerScenarios":"Thrown at pkg/reloader/reloader.go:394 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure tmp and output files are on the same filesystem.","Check output directory permissions.","Investigate whether another process removed the path."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}