Skip to content

ci: retry the compile gate on dependency-resolution failures only - #181

Merged
Episkey-G merged 1 commit into
masterfrom
ci/retry-on-resolution-failure
Aug 25, 2026
Merged

ci: retry the compile gate on dependency-resolution failures only#181
Episkey-G merged 1 commit into
masterfrom
ci/retry-on-resolution-failure

Conversation

@Episkey-G

Copy link
Copy Markdown
Collaborator

Why

ci-syntax went red on codegen PR #180, and it wasn't the code:

Unresolveable build extension: Plugin org.sonatype.central:central-publishing-maven-plugin:0.8.0
  or one of its dependencies could not be resolved
Failed to read artifact descriptor for org.sonatype.central:central-publishing-maven-plugin:jar:0.8.0

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 a compile-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.count

Because it does nothing here. Since Maven 3.9 the default transport is maven-resolver's HttpTransporter, not wagon — verified with mvn -X:

[DEBUG] Using transporter HttpTransporter with priority 5.0 for https://repo.maven.apache.org/maven2

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-syntax now calls scripts/mvn-compile.sh, which runs mvn -B -DskipTests compile and 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

path result
normal compile exit 0, 1 attempt — 51 Compiling lines over 52 modules, no Nothing to compile
real compile error exit 2, 1 attempt, returns in 3s, logs "编译失败(非依赖解析问题),不重试"
resolution failure (mirror pointed at an unreachable host) exit 1, 3 attempts, 44s total — the 10s + 30s backoff

The normal-compile row was checked against the stale-target/ trap: a warm build can exit 0 having compiled nothing, so the Compiling/Nothing to compile counts are quoted rather than just the exit code.

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 退避)
@Episkey-G
Episkey-G merged commit 7ae6e5e into master Aug 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant