Repository navigation
Description
Summary
LOAD DATA can fail the entire statement when MatrixOne starts an internal COS multipart write and the multipart-init request encounters a transient http: server closed idle connection.
This failure is on MatrixOne's write to its shared object storage (POST ...?uploads), not on reading the source CSV. The current QCloud fileservice retries upload parts and multipart completion, but intentionally does not retry InitiateMultipartUpload because that operation creates server-side state without an idempotency key. As a result, one stale pooled-connection failure at init is surfaced directly to SQL and can abort a whole nightly workload.
The fix must not simply restore blind retries: if COS created the upload but its response was lost, retrying can create an unreachable multipart upload. We need a recovery design that handles both pre-request connection failure and commit-ambiguous response loss without leaking uploads.
Environment
- MatrixOne branch:
4.2-dev - MatrixOne commit:
dad3554830240904588d7c0a812f42142c791a9a - Nightly run/job: run 33647265452 / job 100309846959
- Workload: TPCC 100 warehouses,
bmsql_stockload - Topology: one TP CN, two AP CNs, one TN
- Failure time:
2026-09-02 15:46:18 UTC
Observed failure
ERROR 1105 (HY000) at line 1:
Post "https://<redacted-cos-bucket>/<internal-object>?uploads":
http: server closed idle connection
The ?uploads request identifies COS multipart initialization, rather than an upload-part request.
Timeline:
15:46:12 UTC: the preceding TPCCbmsql_order_lineload and row-count check completed successfully.15:46:13 UTC:bmsql_stockload started.15:46:18 UTC: MatrixOne's internal multipart-init POST failed withserver closed idle connection; the load case was marked failed.15:46:18–15:46:24 UTC: the followingbmsql_warehouseload succeeded immediately.- The job exited with status 1, but final database cleanup and handoff safety checks succeeded.
Independent counterevidence against a cluster or persistent COS outage:
- All MatrixOne pods were still Running with zero restarts in the final Kubernetes capture; there was no OOMKill or crash.
- Concurrent AP workloads continued loading TPCH 10G, 100G, and 1000G data from COS successfully after the failure.
- Other TPCC tables immediately before and after
bmsql_stocksucceeded. - The
compression/formatmetadata warnings also occur before successful loads and are not the terminating error.
Code analysis
At the tested commit:
- QCloud SDK built-in retries are disabled with
client.Conf.RetryOpt.Count = 0. UploadPartandCompleteMultipartUploadare wrapped in MatrixOne's boundedDoWithRetryContext.InitiateMultipartUploadis called once without that retry wrapper.- The code documents why: init has no idempotency key, so an error without a returned upload ID is commit-ambiguous and a retry may create an orphan upload that the caller cannot abort.
The immediate trigger was a pooled HTTP connection being closed by a peer while idle. The retained evidence cannot identify whether the closing hop was COS itself, a load balancer, NAT, or another network intermediary. Regardless of the hop, this is a normal transient condition that the storage client needs to handle safely.
This is not the same root cause as #25350: that issue fixed MatrixOne periodically calling CloseIdleConnections, and the tested code no longer does that. It is also narrower than #27876: that issue tracks a similar COS error followed by lost terminal delivery, transaction leakage, and a multi-hour client hang. This occurrence failed promptly and cleaned up correctly; the remaining problem is availability and safe multipart-init recovery.
Impact
- A single transient idle-connection closure fails an otherwise healthy bulk load.
- The failed load causes the remaining TPCC and Sysbench family cases to be skipped.
- If the init request reached COS but the response was lost, the current caller has no upload ID and therefore cannot abort the possible server-side multipart state.
- Blind retry would improve apparent availability but could multiply orphan uploads, so it is not an acceptable standalone fix.
Expected behavior
MatrixOne should safely recover from transient multipart-init transport failures when success is known not to have occurred. For commit-ambiguous failures, it should reconcile or bound possible server-side state rather than blindly creating another upload.
If safe recovery is impossible after bounded attempts, SQL should fail promptly with the original storage error, roll back atomically, leave the connection reusable, and ensure possible orphan multipart uploads are eventually reclaimed.
The solution should preserve connection reuse and multipart throughput; globally disabling keep-alive or creating a fresh connection for every upload part would be an excessive performance regression.
Suggested acceptance coverage
- Inject
server closed idle connectionbefore a multipart-init request reaches COS; the write recovers and creates exactly one multipart upload. - Inject response loss after COS has created the upload; no blind duplicate is created, and all server-side multipart state is reconciled or reclaimed within a bounded interval.
- Exhaust recovery attempts; the SQL client receives the original error promptly, with no hang or transaction leak.
- Verify statement atomicity and that the same SQL connection can execute a subsequent query.
- Exercise concurrent multipart writers and cancellation during recovery.
- Assert bounded retries/backoff and low-cardinality metrics for init attempts, ambiguous outcomes, recovered writes, and orphan cleanup.
- Verify there is no material throughput or connection-count regression for normal large loads.
Related
- LOAD DATA fails with COS
server closed idle connectiondue to fileservice forcibly closing idle connections #25350 / fix(fileservice): avoid closing idle upload connections #25458: removed MatrixOne's forced idle-connection cleanup. - fix(fileservice): retry COS multipart init on EOF #26739: initially added multipart-init retry.
- [4.2] Backport fixes for issues #26720 and #25114 #27313: retained the 4.2 fileservice changes but removed blind multipart-init retry after accounting for commit ambiguity and orphan risk.
- [Bug]: INSERT SELECT hangs and leaks transaction after COS upload idle-connection failure #27876: same lower-level COS error in an
INSERT ... SELECT, plus terminal-error loss, leaked transaction, and client hang.
Activity
LeftHandCold commentedon Sep 3, 2026
补充回归定性和时间证据:
dad3554830240904588d7c0a812f42142c791a9a包含#27313(635de0535a)。该 backport 于 2026-08-28 进入4.2-dev。#27313之前,QCloud multipart-init 使用DoWithRetryContext(..., maxRetryAttemps, IsRetryableError);maxRetryAttemps=128,且server closed idle connection被IsRetryableError明确识别为可重试错误。#27313之后,QCloud SDK 内置重试仍被设置为 0,同时InitiateMultipartUpload改为单次调用。因此同一个底层 keep-alive 竞态以前通常会被内部重试掩盖,现在会直接返回给 SQL。4.2-dev后已经有两次相同的用户可见失败:33257970271:Sysbenchsbtest6LOAD DATA 失败;33647265452:TPCCbmsql_stockLOAD DATA 失败。两次都是内部对象写入的
POST ...?uploads返回http: server closed idle connection。bmsql_order_line写入成功;失败后不到 1 秒,后一个bmsql_warehouse又写入成功。由此可排除源 CSV、账号权限、路由、表定义和持续 COS 故障。第一条 multipart-init 错误使并行 LOAD pipeline 取消,后续context canceled是派生结果。因此应定性为:底层触发是 HTTP keep-alive 的瞬时对端关闭竞态;MatrixOne 没有制造该断连,但移除盲重试后没有提供等价的安全恢复路径,造成了
4.2-dev的 LOAD DATA 可用性回归。它不是数据正确性问题。取消原重试有正确的安全动机:
InitiateMultipartUpload是创建 COS 服务端状态的非幂等 POST,没有 idempotency key。请求可能已创建 UploadID、但成功响应丢失;盲目重试会创建额外 UploadID,而调用方无法 abort 未返回的旧 UploadID。原 128 次循环会把一次故障放大为大量 orphan multipart sessions,所以不能简单恢复原逻辑。当前
severity/s0与影响相符:常用 LOAD DATA 路径存在已确认回归并会使整条导入失败,需要尽快修复;现有证据没有跨租户泄露、数据损坏或项目级紧急事故,不建议提升为severity/s-1。[4.2] fix(fileservice): retry COS multipart init before request write (…
fix(fileservice): retry COS multipart init before request write (cher…
Ariznawlll commentedon Sep 7, 2026
该问题最近几天测试未复现,先关闭
fix(fileservice): retry COS multipart init before request write (cher…
fix(fileservice): retry COS multipart init before request write (cher…
fix(fileservice): retry COS multipart init before request write (cher…