Skip to content

fix(fileservice): retry replayable COS PUT on HTTP EOF - #29820

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
LeftHandCold:fix/cos-put-http-eof-29815
Oct 10, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
LeftHandCold:fix/cos-put-http-eof-29815

Conversation

@LeftHandCold

@LeftHandCold LeftHandCold commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #29815

Closes #29815.

What this PR does / why we need it:

The Main Weekly recorded an object-write failure during
insert into ctas_v(id) values (2): the COS SDK returned a RetryError
containing url.Error(Op="Put", Err=io.EOF). Its reader-length diagnostic is
not proof of an invalid source: the real HTTP regression reproduces that
diagnostic with a correct explicit length and a fully consumed body.

QCloudSDK.Write already buffers small objects or restores a seekable source
to its original offset, but the shared retry classifier excludes ordinary EOF.
Consequently this recoverable PUT fails after one request. This is a confirmed
MO recovery gap, not a newly attributed regression or proof of which network
component closed the original connection.

Narrow fix

  • Use a private COS PUT predicate in the two replay-owning Write loops.
  • Preserve all existing retry classifications. Additionally traverse the SDK's
    opaque RetryError and recognize typed HTTP PUT EOF.
  • Reuse existing body replay, attempt limit, context cancellation and backoff.
  • Keep raw source EOF, invalid input length, permanent 403, and GET/POST EOF
    outside this added condition. Do not change the shared classifier or the
    multipart-init/part/completion protocols.
  • Small/empty multipart fallbacks that already delegate to ordinary Write
    benefit from the same fix; no multipart POST replay is added.

There is no new buffering, retry layer, configuration, lock or algorithm.
The successful-attempt path returns before invoking the error predicate, so
there is no added normal-path allocation or I/O. Replaying an ambiguous PUT
may issue another physical request, as existing PUT retries already do; this
does not promise exactly-once provider events or versions.

Validation

The retained regression uses the actual COS SDK and a real HTTP listener.
Its first PUT stores the complete object, then closes the connection without
a response. Both buffered and nonzero-offset seekable writes must recover
using exactly two identical complete bodies, followed by an actual read of
the stored object.

Controls cover wrapped and raw EOF, unchanged shared policy, GET/POST,
403, short source length, cancellation, retry exhaustion, and existing 502,
multipart-init/abort/part-retry behavior. No source-reader or whole-SQL retry
is introduced.

Tested with:

# Exact main baseline reproduces ordinary EOF failure on shanghai50, 5 times.
.agents/skills/mo-dev/scripts/mo-cgo-test -count=5 -v \
  -run '^TestWeeklyCOSPut' -timeout=120s ./pkg/fileservice

# Final fix, retained tests and existing COS/multipart/retry controls.
.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=120s \
  -run '^(TestQCloud|TestCOS|TestDoWithRetryContext|TestIsRetryable|TestServerClosedIdleConnection|TestWrappedNetTimeout)' \
  ./pkg/fileservice

# Adaptive race repetition of only the new shared HTTP fixture.
.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=100 \
  -run '^TestQCloudSDKWriteRetriesHTTPEOF$' -timeout=120s ./pkg/fileservice

# Full owning package, macOS arm64 and Linux amd64 (shanghai50).
.agents/skills/mo-dev/scripts/mo-cgo-test -race -count=1 \
  -timeout=600s ./pkg/fileservice

The first command is an external baseline diagnostic, not a committed
regression asserting buggy behavior. Fix tests live in the existing
qcloud_sdk_test.go and assert the recovered contract.

Go 1.27.1; CPU CGo libraries built from the isolated source worktrees. macOS
uses canonical TMPDIR=/private/tmp: the default /var symlink exposes an
unrelated pre-existing LocalETL directory-sync fault-injection mismatch,
independently reproduced on pristine production source. No tests are skipped
or weakened. Linux uses an isolated disk-backed build/cache directory because
the shared root filesystem was full. Existing services were not modified.

Results: macOS final focused controls passed (1.010s), real-HTTP regression
passed 100 race repetitions (4.742s), and owning package race passed (28.170s).
On shanghai50, all four new focused tests passed (0.071s) and the full owning
package race passed (147.170s, GOMAXPROCS=4, -p 4). Local and remote changed
files have identical SHA-256 hashes. Source baseline is main@62827a1c8b;
the final tested/reviewed commit is 4fdb76b.

After publication, Mergify merged main@888e1ea446 into the branch, producing
head 8c0d609c492f6bb19c5363dc55a9000ee23ae55f. All files in pkg/fileservice,
cgo, go.mod and go.sum are identical to the validated fix revision.
The focused COS/multipart/retry controls were rerun on this exact current
head and passed (1.021s). The first CI run was cancelled by the head update;
the replacement run is in progress, not declared passed.

This validation proves the MO transport-recovery boundary, not the original
COS/LB/NAT closure trigger. It does not substitute for a full SQL rollback or
live-provider Weekly rerun. Self-review found no remaining implementation
blockers; GitHub CI will be reported separately from these completed tests.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@LeftHandCold LeftHandCold left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码复核结论:PASS,未发现需要 REQUEST_CHANGES 的问题。复核对象为 c5874c19a94f5ced3cd047780aa59a94702d7136,base/merge-base 为 e5dd4724f782067e1c76c38c9d2f55cebceda4a9。当前登录账号与 PR 作者同为 LeftHandCold,因此这里只提交 COMMENT,不冒充 GitHub APPROVED。

完整检查了两个文件的全部变更,并追踪 Write → putObject → COS SDK / HTTP、共享 retry classifier / backoff、S3FS 调用及小对象 multipart fallback。

  • 设计归属正确:只有已经拥有可重放 body 的两个 Write 循环使用新条件;复用现有缓冲、原始 seek offset、attempt limit 和取消路径,没有新增状态机、缓存或重试层。是聚焦修复,无需新功能设计文档。
  • 恢复边界准确:SDK 的 RetryError 没有 Unwrap,显式遍历其 Errs 是必要的;新增条件只识别 typed PUT EOF。原始/字符串 EOF、GET/POST EOF、403 和错误长度没有获得新重试条件;原有 502、timeout/reset 等分类保留。multipart-init/part/completion 及其他 provider 路径未改。
  • 数据与回归:每次使用相同 key 和完整原始内容;seekable 分支恢复非零原始偏移。真实 HTTP 测试模拟“对象已写完但响应丢失”,断言恰好两次完整相同 body,再从存储端读取验证。重复物理 PUT 的版本/事件语义沿用已有重试约定,不承诺 provider exactly-once。
  • 性能:成功时 DoWithRetryContext 在调用 predicate 前返回;没有新增正常路径的数据复制、锁、goroutine 或 I/O。EOF 故障路径可能多次 PUT,使用已有预算,不影响健康请求路径。
Unhappy-path 复核结果
Q1 清理责任 生产侧没有新增持久资源;每次请求/响应仍由原 HTTP/SDK 路径负责,source 所有权不变。测试显式关闭 hijacked connection、read body 和 server。
Q2 等待终止 PUT 使用原 context,backoff 可被取消,attempt 数有限;取消与耗尽有直接 oracle。没有新增锁或等待依赖,也没有把已有 source 读取契约宣称为新的超时保证。
Q3 增长边界 复用单份已缓冲内容或原 seeker,不累计每次重试的 payload;测试观测 channel 有固定容量且发送不阻塞。

验证记录:

  • 本轮 Go 1.27.1 gofmt、git diff --check 通过,隔离 review worktree 干净。
  • 核对保留的四个新增测试的实际命名 PASS 输出(Linux focused 0.071s),以及作者的 COS/retry/multipart controls、HTTP fixture race×100、macOS/Linux owning-package race 终态日志。两个变更文件的 SHA-256 与已验证文件完全一致。
  • 对比已复测 revision 8c0d609c 与当前 head:fileservice、moerr、perfcounter、trace、metric、logutil、cgo、thirdparties、Makefile、go.mod/go.sum 均无变化;聚焦 HTTP/retry 证据仍适用。更早的 owning-package 结果是历史证据,不替代最新完整 CI。
  • 当前 head 的 CI run shared build 和 UT Coverage 已 success;Ubuntu UT、SCA 与相关 BVT 仍在运行,未宣称全 CI 通过。
  • 本轮未重复启动 MO、live COS 或重跑整包 UT。真实 SDK/ObjectStorage HTTP fault→Write→Read 是本修复的消费者验证;完整 SQL rollback、原 Weekly 的网络关闭触发点及 live-provider 重跑不在这份验证结论内。
  • 当前没有需要复核闭环的人工 review threads。

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep review of base/merge-base e5dd4724f782067e1c76c38c9d2f55cebceda4a9 → head c5874c19a94f5ced3cd047780aa59a94702d7136. APPROVE: no remaining blocker found. No subagents; no production source changes.

Design and responsibility: the fix belongs in the two QCloudSDK.Write loops that already own replayable bodies. The additional private predicate preserves the shared classifier and traverses the COS SDK's opaque RetryError only to recognize typed HTTP PUT EOF. Reusing the existing buffer/original seek offset, retry budget, context and backoff is appropriate; there is no new retry state machine, storage, configuration or execution path. This ordinary recovery fix is exempt from the feature-design-document gate.

Read every changed hunk: implementation +21/-2 in one file, tests +181/-0 in one file, documentation 0. Traced S3FS → Write → countingReader → pinned COS SDK Object.Put/net-http, and the reverse read path. Checked the unchanged multipart-init/part/completion paths, including the small/empty fallback into ordinary Write. The added EOF condition does not enable POST/GET or raw source-EOF replay. The existing SDK retry count is zero, so this does not add a nested transport retry budget.

Adversarial boundary: the peer can store the complete object and then lose its response. Both buffered and nonzero-offset seekable cases recover using exactly two identical complete bodies and an actual subsequent read of stored bytes. Nearest negative controls preserve 403 and short-source errors; cancellation/exhaustion retain bounded termination. Q1: HTTP/SDK owns response cleanup and Write retains source ownership; Q2: existing context-aware backoff/attempt limit, with no new wait dependency; Q3: one buffered payload or original seeker, no per-attempt retained payload collection. Existing source-reader blocking contracts are not changed or claimed to become cancelable.

Performance: healthy writes return before evaluating the predicate, so there is no added normal-path allocation, copying, lock or I/O. An EOF failure can issue additional physical PUTs under the existing budget. As with existing ambiguous PUT retries, this is byte-level replay, not an exactly-once promise for provider versions/events. No TP throughput benchmark is claimed.

Comment closure: read issue #29815 and its substantive validation comment, this PR's author self-review, and all review threads (none). The requested recovery boundary is addressed; identifying the original COS/LB/network closure remains outside this fix.

Validation:

  • Exact-head isolated Darwin/arm64, Go 1.27.1, native prerequisites built from this source (supported pinned ONNX prebuilt reuse). COS/HTTP/multipart/retry controls passed under -race, 3.971s; all four new tests selected and passed.
  • TestQCloudSDKWriteRetriesHTTPEOF measured 0.03s; adaptive budget selected 100 same-process race repetitions, all passed (5.081s).
  • Reused exact-head CI run 38032411756: completed success, owning FileService selected in the resource-heavy race-test group; required CI green. Author historical macOS/Linux package runs remain supplemental evidence.
  • git diff --check passed and isolated source worktree is clean. No live-COS/Weekly or complete SQL rollback rerun was performed; the actual SDK HTTP write/read boundary is the consumer oracle for this scoped fix.

@mergify mergify Bot added the queued label Oct 10, 2026
@mergify

mergify Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-10 08:43 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-10 08:56 UTC · at 7c5e799cf6b907ccd0251c402e03e65f35cc2c74

This pull request spent 13 minutes 8 seconds in the queue, with no time running CI.

Reason

Pull request #29820 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

This branch was previously deployed

1 inactive deployment
ci — 7c5e799c Deployed Oct 10, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: COS replayable PUT fails immediately on plain HTTP EOF despite available safe retry

3 participants