Skip to content

[Bug]: LOAD DATA fails on transient COS multipart-init idle-connection close without safe recovery #28028

Closed

Description

@XuPeng-SH

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

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:

  1. 15:46:12 UTC: the preceding TPCC bmsql_order_line load and row-count check completed successfully.
  2. 15:46:13 UTC: bmsql_stock load started.
  3. 15:46:18 UTC: MatrixOne's internal multipart-init POST failed with server closed idle connection; the load case was marked failed.
  4. 15:46:18–15:46:24 UTC: the following bmsql_warehouse load succeeded immediately.
  5. 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_stock succeeded.
  • The compression / format metadata 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.
  • UploadPart and CompleteMultipartUpload are wrapped in MatrixOne's bounded DoWithRetryContext.
  • InitiateMultipartUpload is 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

  1. Inject server closed idle connection before a multipart-init request reaches COS; the write recovers and creates exactly one multipart upload.
  2. 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.
  3. Exhaust recovery attempts; the SQL client receives the original error promptly, with no hang or transaction leak.
  4. Verify statement atomicity and that the same SQL connection can execute a subsequent query.
  5. Exercise concurrent multipart writers and cancellation during recovery.
  6. Assert bounded retries/backoff and low-cardinality metrics for init attempts, ambiguous outcomes, recovered writes, and orphan cleanup.
  7. Verify there is no material throughput or connection-count regression for normal large loads.

Related

Activity

  1. added
    kind/bug
    severity/s0
    on Sep 3, 2026
  2. LeftHandCold commented on Sep 3, 2026

    @LeftHandCold
    Collaborator

    补充回归定性和时间证据:

    1. 失败运行使用的 MatrixOne SHA dad3554830240904588d7c0a812f42142c791a9a 包含 #27313(635de0535a)。该 backport 于 2026-08-28 进入 4.2-dev。
    2. #27313 之前,QCloud multipart-init 使用 DoWithRetryContext(..., maxRetryAttemps, IsRetryableError);maxRetryAttemps=128,且 server closed idle connection 被 IsRetryableError 明确识别为可重试错误。
    3. #27313 之后,QCloud SDK 内置重试仍被设置为 0,同时 InitiateMultipartUpload 改为单次调用。因此同一个底层 keep-alive 竞态以前通常会被内部重试掩盖,现在会直接返回给 SQL。
    4. 变更进入 4.2-dev 后已经有两次相同的用户可见失败:
      • 2026-08-29,run 33257970271:Sysbench sbtest6 LOAD DATA 失败;
      • 2026-09-02,run 33647265452:TPCC bmsql_stock LOAD DATA 失败。
        两次都是内部对象写入的 POST ...?uploads 返回 http: server closed idle connection。
    5. 9 月 2 日事件中,前一个 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。

  3. Ariznawlll commented on Sep 7, 2026

    @Ariznawlll
    Collaborator

    该问题最近几天测试未复现,先关闭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions