Skip to content

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

Closed

Description

@LeftHandCold

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Related, but not the same remaining defect:

Exact-symbol, plain-EOF, and COS/PUT/retry searches of open and closed Issues found no accurate existing tracker for this gap.

Branch Name

main

Commit ID

  • Observed and independently reproduced: 72d4a49db7d750520e1a1654cb6091fc7169882b.
  • Source rechecked against fetched main 0ccc989731f9c2b40d31554a44ca505c656c0e62: qcloud_sdk.go, error.go, retry.go, and go.mod are unchanged from the reproduced revision. The newer revision was not independently started as a SQL service.

Other Environment Information

Actual Behavior

At 2026-10-09 21:27:32.053 UTC / 2026-10-10 05:27:32.053 CST, MOTR case issue_26232_view_default_ctas failed while writing an object to COS:

[DoneWithErr] Write Sync error
can't get reader content length, unkown reader type;
Put "https://<cos-endpoint>/<run-prefix>/data/<object>": EOF

The exact failing SQL was:

insert into ctas_v(id) values (2);

The preceding CTAS creation had succeeded. This is therefore not proof that CTAS construction, its default expression, or its original Issue regressed.

The object write error propagates through objectio/writer.go, the internal SQL executor, and frontend SQL error handling. One transient transport EOF fails this INSERT even though QCloudSDK.Write already owns a replayable buffered/seekable source.

Expected Behavior

For an ordinary object PUT whose body can be replayed from the original offset, recognize a transport EOF as a recoverable attempt failure and apply a bounded, context-aware retry with the same key and complete body. Preserve prompt failure on cancellation, exhausted recovery, permanent authorization errors, and invalid source data.

Do not implement this by blindly retrying state-creating multipart-init POST, retrying a consumed non-seekable body, matching every error string containing EOF, or hiding arbitrary statement failures behind whole-SQL retries.

Steps to Reproduce

The failure does not require a whole Weekly run or a COS credential:

  1. At the reproduced commit, construct a QCloudSDK with a real cos.Client pointing to a loopback HTTP test server. Disable SDK retries as NewQCloudSDK does (RetryOpt.Count=0). Disable CRC in this minimal server fixture, which does not implement COS CRC headers.
  2. Provide a non-empty buffered payload and a matching size hint to the real QCloudSDK.Write method.
  3. On the server's first PUT, consume the whole body and close the TCP connection without sending any HTTP response. On a later PUT, return HTTP 200.
  4. Observe that Write returns *cos.RetryError containing Put ...: EOF after one request. The healthy second attempt is never made.
  5. As a counterfactual, allow exactly one replay of this same write with a fresh reader after the EOF. It succeeds after two requests; both requests contain the identical complete payload.

Independent controls using the same production Write entry point:

First-attempt condition Attempts Outcome
Transport io.EOF 1 Write fails
Transport io.ErrUnexpectedEOF 2 Write succeeds; both bodies are complete and identical
Real HTTP peer closes after consuming PUT body 1 Write fails with the same error shape as the Weekly log
Same real peer closure, one bounded replay with a fresh body 2 Write succeeds; identical object bytes

All four conditions were repeated five times with -count=5; the diagnostic assertions passed every time. Passing diagnostics mean that the production failure was reproduced as expected, not that a production fix has been implemented. This validation exercises the actual MO COS write method and the actual COS SDK, not only a copied error classifier.

Additional information

Confirmed MO-side mechanism

  1. NewQCloudSDK disables built-in SDK retries. MatrixOne is responsible for recovery.
  2. QCloudSDK.Write buffers small objects and constructs a fresh bytes.Reader per retry; for a seekable source it restores the original offset before each PUT. Thus the known replay capability is already owned by this outer method.
  3. putObject wraps the source in countingReader and invokes COS Object.Put once.
  4. The SDK returns a *cos.RetryError containing a *url.Error wrapping ordinary io.EOF when the peer closes without response headers.
  5. IsRetryableError inspects the inner SDK errors but recognizes io.ErrUnexpectedEOF, not io.EOF. The ordinary EOF is not a timeout, reset, or one of the recognized string cases. The outer write loop stops after its first attempt.

Source owners at the exact reproduced revision:

The SDK's can't get reader content length, unkown reader type prefix is not, by itself, proof of a missing MO size hint. countingReader is not one of the SDK's recognized length-bearing reader types; the SDK can retain that diagnostic while still sending a request with the supplied ContentLength. The real-HTTP fixture reproduces the same prefix despite a valid explicit size hint and receipt of the whole payload. The terminal transport error is EOF.

Regression classification

This is a newly tracked availability defect, not a demonstrated recent regression. The classifier already omitted ordinary EOF when #24917 added replayable PUT retry on 2026-06-11. No introducing commit for the Weekly occurrence, and no code change causing the connection closure, has been established.

What remains unknown

  • The retained production evidence cannot identify whether COS, a load balancer, NAT, or another intermediary closed the connection.
  • The test reproduces the MO recovery gap, not the original infrastructure trigger or production request count.
  • No permanent data loss, statement atomicity violation, whole-CN crash, or transaction leak is asserted.
  • This report does not establish a tested affected-version range for 4.2.

Narrow acceptance criteria for a future fix

  • Exercise the real COS write path for both buffered and seekable sources; preserve original seek offsets and identical complete bytes after replay.
  • Cover ordinary wrapped HTTP EOF separately from io.ErrUnexpectedEOF.
  • Preserve bounded backoff, caller cancellation/deadline, and fail-fast permanent errors.
  • Do not expand multipart-init recovery or other non-idempotent operations without their own proof.
  • Distinguish HTTP response EOF from a permanently truncated input reader. Do not broaden shared retry policy without auditing the affected callers.
  • Retain statement rollback and connection-reuse checks when validating through SQL.

Activity

  1. LeftHandCold commented on Oct 10, 2026

    @LeftHandCold
    CollaboratorAuthor

    Root cause confirmed; narrow main fix and validation

    Fix PR: #29820

    Source baseline: main@62827a1c8bfb1c846c0f3528e71503baacb3b3bc.
    Tested/reviewed fix: 4fdb76b82bc821ac0ad340a46f29b4946fc4d61f.
    Upstream was rechecked at 888e1ea4469b6c2bf7a23c31f3376654cb8a30cc before
    publication; its newer commit does not change the COS/retry contract.

    Confirmed MO-side cause: the COS SDK returns an opaque RetryError
    containing url.Error{Op: "Put", Err: io.EOF}. The shared classifier rejects
    ordinary EOF, so QCloudSDK.Write stops after the first attempt even though
    it already owns a buffered or seekable, replayable body. This is not an
    invalid-content-length diagnosis: the real HTTP listener receives the entire
    correctly sized body and produces the same SDK error shape.

    Original infrastructure trigger remains unknown. The evidence does not
    identify whether COS, a load balancer, NAT or another peer closed the
    production connection. This fix addresses the demonstrated MO recovery gap,
    not that upstream trigger. No recent introducing PR has been established.

    Before/after evidence on shanghai50

    No existing services or shared test data were modified. Validation used an
    isolated Linux amd64 worktree, the actual COS SDK, and a real HTTP listener.

    • Unmodified production baseline, repeated 5 times: ordinary EOF returns
      failure after 1 PUT; unexpected EOF control recovers after 2 PUTs;
      closing the real connection after consuming the whole body reproduces the
      Weekly error; a single bounded replay succeeds with identical complete bytes.
    • Fixed retained regression, buffered and nonzero-offset seekable branches:
      the server stores the first complete object but loses its response. The write
      recovers after exactly 2 identical PUTs, and a subsequent real read of the
      stored object returns the expected content.
    • All four new focused tests actually executed and passed: 0.071s.
    • Full pkg/fileservice package with -race -count=1 passed: 147.170s
      (GOMAXPROCS=4, -p 4). Changed file hashes match the local reviewed files.
    • Local macOS: focused COS/multipart/retry controls passed; retained real-HTTP
      regression passed 100 race repetitions; full owning-package race passed.

    Risk containment and reviewed boundaries

    • Only the two replay-owning COS PUT loops use the additional private predicate.
    • Existing attempt limits, backoff, cancellation, buffering and original-offset
      replay are reused. No new retry layer, global state, lock or algorithm.
    • Raw source EOF, invalid length, permanent 403 and GET/POST EOF do not gain
      this retry condition. Cancellation and exhaustion have explicit controls.
    • The shared classifier, other providers, cache policies and multipart
      initiation/part/completion protocols remain unchanged. Small/empty multipart
      fallbacks already using ordinary Write benefit at that same PUT boundary.
    • Successful writes return before calling an error predicate: no added
      normal-path allocation, buffering or I/O. Ambiguous PUT recovery may produce
      another provider request/version/event, as existing PUT retries already do.
    • Self-review found no unresolved implementation blockers. This is boundary
      validation, not a full SQL rollback or live-COS Weekly rerun.

    The ready-for-review PR targets main, uses the repository template and
    references this Issue. At publication, CI preflight passed; build/UT/SCA were
    still running or queued, not declared passed.

    Subsequent integration update: Mergify automatically merged the latest main,
    producing head 8c0d609c492f6bb19c5363dc55a9000ee23ae55f. The FileService code,
    tests, CGo sources and Go dependencies are unchanged from the validated fix.
    Focused COS/multipart/retry controls were rerun on that exact head and passed
    (1.021s). The first CI run was cancelled by this synchronization, not by a
    test assertion; replacement run https://github.com/matrixorigin/matrixone/actions/runs/38032094089
    is running, with no failed checks observed at read-back.

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

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions