Add retry for os.rename in atomicFileWriter
还没有人认领这个 Issue。
评估
调研方向
从 atomicwriter/atomicwriter.go 第 155 行附近开始,该处调用了 os.rename,并检查周围的 atomicFileWriter 流程。使用提供的、已启用 Microsoft Defender 的 Windows 复现环境,验证临时重命名失败会进行重试,并且成功的写入仍能无错误地完成。
由索引模型根据 Issue 内容生成。
描述
Problem: Updating files using atomicFileWriter can fail during rename on Windows, due to AV software holding the file handle.
Reproduction steps:
Run this simple program on Windows
package main
import (
"fmt"
"log"
//"time"
"github.com/moby/sys/atomicwriter"
)
func main() {
data := []byte(`{
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": false
}`)
var count uint64
fmt.Println("starting the test")
for {
count++
//time.Sleep(50 * time.Millisecond)
err := atomicwriter.WriteFile("test_daemon.json", data, 0o644)
if err != nil {
log.Fatalf("write failed after %d iterations: %v\n", count, err)
}
}
}
It will fail with below error after 1 or 2 minutes:
2026/04/24 12:16:24 write failed after 7807 iterations: rename C:\Users\azureuser\tmp\.tmp-test_daemon.json854562021 C:\Users\azureuser\tmp\test_daemon.json: Access is denied.
exit status 1
I just have Microsoft Defender on this system with default configuration.
Some environments (finance sector customers) have strict security policy where customers cannot exclude folders from AV scans.
Adding a retry around os.rename at https://github.com/moby/sys/blob/main/atomicwriter/atomicwriter.go#L155 can avoid this transient rename failure.
- 主要语言
- Go
- 星标
- 103
- 派生
- 64
- 平均合并
- 6 分钟
- 30 天内合并 PR
- 2
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
moby/sys 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
-
devices: ignore .incus-mounts in GetDevices可能已有人在做 @SashaMIT 于 13 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
-
[userns-remap] Bug: ToHost incorrectly maps non-root container UID to root when it collides with RootPair可能已有人在做 @okhowang 于 79 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
-
capability.LastCap fails when /proc/sys/kernel/cap_last_cap is unavailable可能已有人在做 @kolyshkin 于 2 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 50/100
-
难度 3/5 1-2 天 新手友好度 74/100
相似的 Issue
-
bug raised-by:verifier
难度 2/5 1-3 小时 新手友好度 76/100
medici-finance/assay#4177 ·
维护者通常 1 天内回复
-
bug: admin user creation silently ignores role可能已有人在做 @bfs2021 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 76/100
eugenioenko/autentico#553 ·
维护者通常 1 天内回复
-
sidecar: --moriio-parallel-dispatch omits remote_request_id, so a vLLM NixlPushConnector decode dies with KeyError可能已有人在做 @xintin 今天认领。 未关闭kind/bug needs-triage
难度 2/5 1-3 小时 新手友好度 78/100
llm-d/llm-d-router#3607 ·
维护者通常 1 天内回复
-
automation models
难度 1/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 91/100
维护者通常 1 天内回复