git push --mirror卡住是否因Azure API速率限制?如何排查?
我的bash脚本执行以下命令:
git push lfs --all git push --mirror <remote>
现在脚本卡住了,进程链及strace输出如下,所有进程都卡在read(fd, )系统调用上:
[root@<hostname>]# ps -aef | grep -i "<repo-script>" root 250657 5276 0 Mar22 ? 00:00:00 /bin/bash <repo-script> root 1515495 1509938 0 13:51 pts/1 00:00:00 grep --color=auto -i 434_taskidrepo [root@<hostname>]# ps -aef | grep 250657 root 250657 5276 0 Mar22 ? 00:00:00 /bin/bash <repo-script> root 337428 250657 0 Mar22 ? 00:00:00 /usr/bin/git -c core.askPass=<pat-script-path> push --mirror <remote-repo> root 1515578 1509938 0 13:51 pts/1 00:00:00 grep --color=auto 250657 [root@<hostname>]# strace -p 337428 strace: Process 337428 attached read(3, ^Cstrace: Process 337428 detached <detached ...> [root@<hostname>]# ps -aef | grep 337428 root 337428 250657 0 Mar22 ? 00:00:00 /usr/bin/git -c core.askPass=<pat-script-path> push --mirror <remote-repo> root 337429 337428 0 Mar22 ? 00:00:03 /usr/libexec/git-core/git-remote-https <remote-repo> <remote-repo> root 1515785 1509938 0 13:52 pts/1 00:00:00 grep --color=auto 337428 [root@<hostname>]# strace -p 337429 strace: Process 337429 attached read(6, ^Cstrace: Process 337429 detached <detached ...> [root@<hostname>]# ps -aef | grep 337429 root 337429 337428 0 Mar22 ? 00:00:03 /usr/libexec/git-core/git-remote-https <remote-repo> <remote-repo> root 337444 337429 0 Mar22 ? 00:00:01 /usr/libexec/git-core/git send-pack --stateless-rpc --helper-status --thin --no-progress <remote-repo>/ --stdin root 1515972 1509938 0 13:53 pts/1 00:00:00 grep --color=auto 337429 [root@<hostname>]# strace -p 337444 strace: Process 337444 attached read(5, ^Cstrace: Process 337444 detached <detached ...> [root@<hostname>]# ps -aef | grep 337444 root 337444 337429 0 Mar22 ? 00:00:01 /usr/libexec/git-core/git send-pack --stateless-rpc --helper-status --thin --no-progress <remote-repo>/ --stdin root 1516114 1509938 0 13:53 pts/1 00:00:00 grep --color=auto 337444 [root@<hostname>]# strace -p 337444 strace: Process 337444 attached read(5,
可能原因与确认方法
是否可能是Azure API速率限制?
有可能。Azure对Git批量操作(比如镜像推送)设有API速率限制,当请求量超出配额时,会返回HTTP 429状态码,甚至暂时挂起连接,导致进程卡在等待响应的read()调用上。但这种卡住也可能是网络中断、远程仓库故障、身份验证异常等其他原因,需要进一步验证。
确认方法
开启Git详细日志:执行带调试参数的推送命令,查看是否有速率限制相关响应:
GIT_CURL_VERBOSE=1 git push --mirror <remote>如果日志中出现
HTTP/1.1 429 Too Many Requests或Azure明确的速率限制提示,即可确定是该原因导致。检查Azure配额状态:若使用Azure DevOps,可在Azure门户或DevOps项目的「设置」-「速率限制」中查看当前API调用的配额使用情况,确认是否已达上限。
低峰期重试:在非业务高峰期重新执行脚本,若能成功完成推送,基本可判断是高峰期速率限制导致。
网络抓包分析:用
tcpdump或tshark抓取与Azure仓库的通信包,查看是否收到429响应,或连接是否异常中断。
关于进程卡在read()的说明
Git的push --mirror会启动多层子进程(git-remote-https负责HTTP通信,git send-pack负责数据发送),这些进程卡在read()调用,说明它们正在等待远程端的响应。如果是速率限制,Azure会先返回429响应,之后进程可能进入重试等待;如果是其他问题(如连接断开),进程也会持续等待直到超时,但仅从当前strace输出无法直接区分,必须结合日志或抓包结果判断。
内容的提问来源于stack exchange,提问作者DevSynth

