Repository navigation
fix(fileservice): abort canceled parallel multipart uploads - #29312
Conversation
fengttt
left a comment
There was a problem hiding this comment.
This looks correct to me; only minor nits below.
I checked the full WriteMultipartParallel functions, not just the diff:
- Abort after cancellation works. The deferred
AbortMultipartUploadruns whenevererr != niland usescontext.WithoutCancel(parentCtx), so it still goes out after the context is canceled. The canceled upload is cleaned up rather than leaked. - Removing
if len(parts) == 0 { return nil }is safe. Empty input (firstPart == nil) and input belowminMultipartPartSizetake the single-Writepath before a multipart upload is created. On the multipart pathsendJob(firstPart)always counts at least one part. So "no part finished" now always hits the existingmultipart upload incompleteerror and the abort, instead of returning success with no object. That was the real hazard: a caller would believe the object was written. - Coverage is complete. AWS and COS are the only real implementations.
objectStorageHTTPTrace,objectStorageMetricsandobjectStorageSemaphoredelegate to them. - The read loop was already right. A
readChunkerror, including cancellation while acquiring buffer budget, goes throughsetErr. The silent path was only in the part workers, which is what this fixes. - The tests hit the right boundary. They cancel after a worker holds its slots and assert aborted, not completed, with no parts. The AWS init-cancellation case is a good addition.
Returning the raw ctx.Err() is also the right shape: callers above (e.g. the parallel-scope scheduler) recognise a canceled sibling with errors.Is(err, context.Canceled).
Possible follow-up, not for this PR: workers wait for the upload semaphore / slots without watching ctx, and check it only after acquiring them. That's correct and doesn't leak, but with many queued parts a canceled upload drains the queue slot by slot before returning.
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Queued — the merge queue status continues in this comment ↓. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
GPT-6 high review — APPROVE.
Reviewed the current diff and affected cancellation/abort paths. The cancellation propagation fix and abort behavior are covered; no blocking findings.
Merge Queue Status
This pull request spent 54 seconds in the queue, including 4 seconds running CI. Required conditions to merge
|
## What type of PR is this? - [x] BUG - [x] Improvement ## Which issue(s) this PR fixes: Fixes #30737 ## What this PR does / why we need it: Cancelling asynchronous CSV/JSON conversion can leave a missing batch result and make export finalization spin indefinitely. Finalization now waits on ordered results or cancellation, releases completed entries, and rejects incomplete closed streams. ExportConfig owns cancellation and joining of conversion workers, file pipes, the sink, and the per-file cancellation callback. Cleanup preserves the primary error's concrete identity and keeps request metadata alive until all users exit. Ordinary OUTFILE, DATA BRANCH CSV, and stored-result dumping use this cleanup boundary. DATA BRANCH coordination runs outside the converter pool and observes producer cancellation once while draining results. Stored-result dumping creates its own cancellation context and passes it to the sink. A known header/source error therefore cancels a context-cooperative sink before joining, even if it is waiting on existence checks or admission rather than consuming the pipe. Dump remains synchronous and allocates no unused conversion queue. The parent request, borrowed shared service, process, and saved metadata retain their ownership. Rebased onto the target branch and aligned all `ExportConfig` method receiver names, resolving CI staticcheck ST1016 without changing cleanup behavior or suppressing diagnostics. The 4.2-dev PR also backports #29344 for #29266: unknown-size empty S3 writes publish zero-byte objects, and failed multipart writes reach bounded Abort cleanup. Sequential/parallel Abort retains context values, survives caller cancellation, and has a 30-second deadline. Successful Abort preserves primary error identity. SDK dependencies, nonempty chunk sizing and successful request sequence remain unchanged. ## Validation - Final frontend owning-package normal and full `-race -count=1` suites: **1599 root tests passed in each**, with one existing skip. - Rebase preserved all three functional commits. Backend source and dependencies are unchanged; prior backend evidence remains applicable. - New actual `doDumpQueryResult` regression covers oversized headers, a source-file read failure after sink startup, parent cancellation, primary error identity, joined sink, and continued shared-service/metadata usability. Retained evidence from the identical regression source records **100 race repetitions per branch**; all three scenarios also passed in the post-rebase full race suites. A pre-repair production-function overlay makes the source-error cell fail as expected until independent parent cancellation; the probe cancels and drains itself. - Existing public SQL lifecycle test passed under race: exact CSV contents, destination failure and same-session reuse. Existing multi-block stored-result dump content test passed. - Scoped `go vet`, configured `molint`, formatting, license-eye and incremental configured `golangci-lint` passed. Full affected-package lint reports 41 diagnostics: a separate clean `b7d2cc7b56` worktree produces the identical complete diagnostic set after normalizing line offsets. No new findings, no ST1016, no suppression. License-eye checked all changed files (7 main / 11 release), 0 invalid; policy unchanged. - Separate `gpt-6.1-sol` / `xhigh` design and final complete-PR review passed with no unresolved material blocker. Local results are distinct from remote CI. - Retained backend evidence remains applicable: fileservice owning-package suite (299 roots), affected AWS/S3 race tests (51 roots), controlled HTTP Abort deadlines/errors, real SQL empty-object publication, and combined SQL cancellation/prepared reuse. The later unmodified-binary blackbox comparison reproduced the 4.2 baseline hang, while this PR's export lifecycle passed 32/32 timed cancellations with same-session health and correct normal CSV contents. No backend source or dependencies changed in this follow-up. Local validation artifacts: `/home/xupeng/.codex/issue-to-pr/matrixone/30737/rebase-review/` (`scope.json`, `results.json`, `run-validation.sh`, `*-normal.jsonl`, `*-race.jsonl`, `*-public.jsonl`, `*-vet.log`, `*-molint.log`, `*-lint.log`, `*-license.log`, exit receipts). The release baseline comparison is `42-lint-comparison.json`; retained stress/negative controls are in the adjacent `review-ci-repair/` directory. ## Performance and limits Retains asynchronous conversion. Blocking finalizer waits replace busy spinning. Stored-result dumping adds one child context; it adds no conversion queue, worker or success-path backend request. No broad throughput or long-soak guarantee is claimed. Global admission bounds and arbitrary I/O that ignores cancellation remain outside this fix. The separately tracked borrowed-service SQL DATA BRANCH DIFF issue #30755 is unchanged. Failed S3 writes can wait for the bounded Abort operation; the 30-second cleanup budget does not bound the entire SQL request or arbitrary source readers. Remote reclamation requires a successful Abort. The pre-upload parallel cancellation schedule addressed by main #29312 remains a separate known gap. Remote CI is pending for the updated revision.
What type of PR is this?
Which issue(s) this PR fixes:
issue #29267
What this PR does / why we need it:
Record cancellation observed by multipart part workers in both S3 and COS implementations. Reject an incomplete upload even when no parts finished, so the existing abort path cleans up the owned upload instead of reporting success without creating an object.
Add an AWS regression test that cancels after multipart initialization; retain the existing COS cancellation test.
Validation (Go 1.26.4): focused cancellation tests, full
pkg/fileservicetests, focused and full package race tests, andgo vetpassed. Multipart functions have 89.2% (AWS) and 88.7% (COS) statement coverage. Incrementalgolangci-lint v2.6.2built with Go 1.26.4 passed forpkg/fileservice(0 issues). This does not claim a full-repository lint pass.