ci: retry the compile gate on dependency-resolution failures only - #181
Merged
Conversation
codegen PR #180 的 ci-syntax 红了,原因不是代码: Unresolveable build extension: Plugin org.sonatype.central: central-publishing-maven-plugin:0.8.0 ... could not be resolved 是没能从中央仓库拉到那个插件。它在 pom 里带 <extensions>true</extensions>, Maven 即使只跑 compile 也必须在读取项目阶段先解析它,所以一次网络抖动 就能打断一个纯编译的闸。同期 7 个 codegen PR 里只坏了这一个。 代价不只是要人重跑:自动合并要求 mergeable_state == clean, 一次抖动会让那一轮发布退回人工,并为一个瞬时故障发一条「自动合并受阻」告警。 没有用 -Dmaven.wagon.http.retryHandler.count,那个参数在这里是空转的: Maven 3.9 起默认传输实现是 maven-resolver 的 HttpTransporter 而非 wagon, 实测 mvn -X 输出为 `Using transporter HttpTransporter with priority 5.0`, wagon 的参数根本不会被读到。native transport 自己的重试是开着的, 而 #180 仍然失败,说明那次不是可重试的 HTTP 条件。故只能在命令这一层重试。 判据只对解析类失败重试,编译错误立刻失败——无差别重试会让一个真实的 编译错误在 50 个 module 上跑三遍,把最该快速反馈的失败拖慢三倍。 本地实测三条路径: 正常编译 exit 0,1 次尝试(51 个 Compiling / 52 个 module) 真实编译错 exit 2,1 次尝试,3 秒返回,日志写明「不重试」 解析失败 exit 1,3 次尝试,44 秒(10s + 30s 退避)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
ci-syntaxwent red on codegen PR #180, and it wasn't the code:Maven simply could not fetch that plugin. Because it is declared with
<extensions>true</extensions>, Maven has to resolve it during the project reading phase even for acompile-only invocation — so one network hiccup can break a gate that never needed the publishing plugin in the first place. One of the seven codegen PRs in that window hit it.The cost isn't only a manual re-run. Auto-merge requires
mergeable_state == clean, so a single flake pushes that release back to a human and fires an "auto-merge blocked" alert for what was a transient fault.Why not
-Dmaven.wagon.http.retryHandler.countBecause it does nothing here. Since Maven 3.9 the default transport is maven-resolver's
HttpTransporter, not wagon — verified withmvn -X:The wagon property is never read. The native transport has its own retry (
aether.connector.http.retryHandler.count, on by default) and #180 failed anyway, which means that attempt wasn't a retryable HTTP condition. So the retry has to live one level up, around the command.What it does
ci-syntaxnow callsscripts/mvn-compile.sh, which runsmvn -B -DskipTests compileand retries only when the output matches a resolution failure (Unresolveable build extension,Failed to read artifact descriptor,Could not transfer artifact, connection resets/timeouts, …). Up to 3 attempts, backing off 10s then 30s.A compilation error is not retried. Retrying indiscriminately would run a genuine compile error three times across 50 modules and triple the feedback time on exactly the failure you most want to hear about quickly.
Verified locally
Compilinglines over 52 modules, noNothing to compileThe normal-compile row was checked against the stale-
target/trap: a warm build can exit 0 having compiled nothing, so theCompiling/Nothing to compilecounts are quoted rather than just the exit code.