Repository navigation
fix(frontend): terminate CSV export reliably on cancellation - #30741
Conversation
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? |
|
mo-bot review · Commit: "interrupted" |
|
mo-bot review · Commit: "interrupted" |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: b9ffa493e4dbbe3e68c3e4ac3f315208f3cf2cd2
Assessment: request_changes
Reviewed the complete seven-file delta and affected callers. Centralizing cancellation and cleanup in ExportConfig is appropriate, but stored-result dumping does not establish the cancellation ownership required by the new cleanup boundary.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
- P2
pkg/frontend/query_result.go:781: A stored-result dump rejects an oversized header while its asynchronous destination is waiting before consuming the pipe, such as during remote existence checking or admission.
Impact: The already-known export error cannot return until the sink completes or the caller cancels. This caller assigns ctx without initializing exportParam.cancel, so finish cannot abort the sink before joining it. Create an owned cancelable export context and pass it to openNewFile.
Evidence: The new deferred finish reaches closeFile's AsyncGroup.Wait; closing pipe endpoints does not interrupt a sink waiting elsewhere. A deterministic test-only overlay exercised doDumpQueryResult: TestReviewDumpHeaderFailureCancelsSink remained blocked until explicit caller cancellation, while TestReviewInitializedExportCancelsSink passed. See dump-probe-v2.jsonl and checks/1792574297180315137-4.json in the diagnostic directory. The sink cooperates with cancellation; this is not the excluded uncooperative-backend case.
Validation:
-
Receipts, clean source fingerprints, commands, log outcomes and native provenance reconciled in /home/xupeng/.local/state/mo-bot/jobs/2850adc000002b2f90fc0bae/attempt-1/review-evidence.json. Isolation preflight and fresh native build passed.
-
Race validation passed: 12 focused regression roots; full frontend suite with 2,508 passed and one skipped; four cancellation roots with 100 repetitions each.
-
Public SQL content, destination-failure and same-session reuse test passed under race. Changed-file formatting and go vet -race for both changed packages passed.
-
The corrected diagnostic probe reproduced the finding with a passing control. Its earlier fixture setup failure was retained and excluded from product evidence.
Limitations:
-
Frozen CI remained pending; local_validation contained no reusable executions. Linked issue #30737's body was not supplied.
-
The failing sink phase was injected, not exercised against live S3. Separate normal-mode full-suite and configured golangci-lint runs were not performed.
-
Performance assessment traced source-level costs; author benchmark claims lacked retained measurements and were not accepted as measured evidence.
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: 4c99b1fde8c05fec16e9e5e4c2532a66d1979619
Assessment: approve
Reviewed the complete seven-file delta and affected callers. ExportConfig coherently owns cancellation, worker joins and file cleanup, preserves primary error identity, and resolves the prior stored-result cancellation defect. Blocking finalization and removal of consumed entries improve termination and retention. No actionable findings remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
Validation:
-
Verified the clean frozen head, complete patch and all seven author source fingerprints. Commands, receipts, hashes and retained logs are recorded in attempt-1/evidence-audit.json and review-evidence.json.
-
Reused matching frontend runs: normal 2,521 passed; race 2,520 passed; each had one existing skip. An explicitly non-race allocation test explains the count difference.
-
Verified fresh public SQL race evidence covering exported content, repeated destination failure and same-session reuse.
-
Reconciled five applicable pre-rebase cancellation stress checks, each with 100 race repetitions, against retained execution evidence and unchanged lifecycle behavior.
-
Verified retained go vet success, configured lint reporting zero issues, and license checks for all seven files. Molint exited zero but retained diagnostics in unchanged code.
-
Read-only evidence audits passed. Product tests were reused rather than rerun.
Limitations:
-
Substantive CI was queued in the frozen snapshot; no CI pass is claimed.
-
No live S3, throughput benchmark or long-soak validation. Existing global admission and non-cooperative backend behavior remain outside this fix.
-
Linked issue #30737 body was absent; review used the frozen PR contract and supplied review concerns.
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: c2decd7cceb2318825e277d12652d4cc0ddb2d03
Assessment: approve
Reviewed the complete seven-file delta and affected callers. ExportConfig coherently owns cancellation, worker joins and file cleanup while preserving primary errors and borrowed resources. The prior stored-result cancellation defect is resolved. Blocking finalization and deletion of consumed entries remove spinning and unnecessary retention, with added bookkeeping confined to export paths. No actionable findings remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1
Validation:
-
Verified the clean frozen head, complete patch and all seven source fingerprints. Reviewed intervening base changes and established that retained export scenarios do not enter the newer LOAD authorization or Kafka branches.
-
Reused matching export implementation evidence: frontend normal suite had 2,521 passing roots; race suite had 2,520. Each had one existing skip; the count difference is an explicitly non-race allocation test.
-
Reconciled public SQL race evidence covering exported content, repeated destination failure and same-session reuse.
-
Verified five cancellation tests with 100 race repetitions each, reconciling source, selections, commands, terminal outcomes and retained receipts or author execution records.
-
Verified retained go vet, configured lint and license results. Lint reported zero issues; molint exited zero with diagnostics outside the changed files.
-
Verified 192 retained native inputs and 13 library hashes against current sources and the matching build receipt.
-
Read-only evidence audits passed, including final receipt 1792596539407237477-3.json. Evidence inventory: /home/xupeng/.local/state/mo-bot/jobs/517d2ae9dafac65111b534df/attempt-1/review-evidence.json.
Limitations:
-
Product tests were reused for unchanged export behavior, not rerun on the current head. Substantive CI remained in progress in the frozen snapshot.
-
No live-S3, throughput benchmark or long-soak validation was performed. Performance conclusions are source-based; global admission and noncooperative I/O remain outside this fix.
-
Linked issue #30737's body was absent; review assessed the frozen PR contract and all supplied review concerns.
c2decd7 to
f0c596c
Compare
|
mo-bot review · Commit: "interrupted" |
|
mo-bot review · Commit: Review completed. Read the assessment. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
mo-bot review · mo-bot-local · review
Commit: f0c596c9fd1976b68d329bc00741ae833055feeb
Assessment: approve
Reviewed the complete seven-file delta and affected callers. ExportConfig coherently owns cancellation, worker joins and file cleanup, preserving primary errors and borrowed resources. The prior stored-result cancellation defect is resolved. Blocking finalization and removal of consumed entries improve termination and retention. No actionable findings remain.
Model: gpt-6-astra / xhigh
Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1
Validation:
-
Independently verified current-head source fingerprints, retained commands, exit records and logs: frontend normal suite passed 2,527 roots; race suite passed 2,526. Each had one existing skip; a non-race allocation test explains the count difference.
-
Verified public SQL race coverage for exact CSV contents, repeated destination failure and same-session reuse, plus stored-result success and cancellation coverage.
-
Reconciled five retained cancellation stress tests with 100 race repetitions each against relevant source and fixture identities.
-
Verified native provenance through the repository owner, retained vet/lint/license results, and fresh formatting and diff checks. Molint exited zero with seven diagnostics outside changed files.
-
Evidence is retained in attempt-1/evidence-audit.json and review-evidence.json. Final audit receipt checks/1792620684375645417-4.json records exit 0 and an unchanged frozen source.
Limitations:
-
Product tests were reused from verified retained evidence; no new runtime tests were executed. Substantive remote CI remained pending in the frozen snapshot.
-
No live-S3, throughput benchmark or long-soak validation. Performance conclusions are source-based; global admission bounds and uncooperative I/O remain outside this fix.
-
Linked issue #30737's body was absent; review assessed the supplied PR contract and all recorded review concerns.
## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to #30704 Related to #30705 ## What this PR does / why we need it JSONLINE OUTFILE → LOAD could reinterpret the literal text `\N` as SQL NULL, and JSONLINE OUTFILE could silently replace invalid UTF-8 bytes with U+FFFD. The JSONLINE reader now distinguishes a JSON null token from a string value. OUTFILE rejects invalid UTF-8 for CHAR, VARCHAR, TEXT, and DATALINK before JSON serialization can silently alter the bytes. A binary-origin DATALINK URL-path counterexample confirms the boundary: raw `FF` bytes remain stored, but the old JSON marshaler emitted `EF BF BD` and returned success. The corrected path returns an explicit JSONLINE invalid-UTF-8 error; a valid DATALINK URL still exports as its ordinary JSON string. No global DATALINK storage/cast validation, CSV behavior, binary wrapper semantics, or upstream #30741 pipe lifecycle is changed. The regression coverage includes literal `\N` versus true NULL, object/array JSONLINE, CSV controls, invalid UTF-8 VARCHAR and DATALINK values, exact DATALINK storage bytes, no replacement-text export, and same-session recovery with a valid URL. ### Validation Exact published candidate: `dd6ce76d6a3246fdd941d8d6fad2caf610b3da38`. - Frontend focused DATALINK conversion test — PASS: `./.agents/skills/mo-dev/scripts/mo-cgo-test -run '^TestVectorValueToJSONRejectsInvalidUTF8Text$' -count=1 -v ./pkg/frontend`. - Embedded public regression on final source — PASS: `./.agents/skills/mo-dev/scripts/mo-cgo-test -run '^TestJSONLineOutfileLoadPreservesTextAndRejectsInvalidUTF8$' -count=1 -v -timeout 180s ./pkg/embed`. It verifies raw stored bytes, explicit malformed-row error, no U+FFFD output, a same-connection query after the error, and exact valid-URL JSON bytes. - Full frontend CGo package — PASS, 15.266s: `./.agents/skills/mo-dev/scripts/mo-cgo-test -p=1 -count=1 -timeout 300s ./pkg/frontend`. - Full embed CGo package — PASS, 358.824s: `./.agents/skills/mo-dev/scripts/mo-cgo-test -p=1 -count=1 -timeout 10m ./pkg/embed`. An earlier run with an explicit 5m total-package budget timed out as `TestSQLFileAccessPeerPersistence` had just started; no assertion failure was reported. The longer run passed. The final named embedded regression was rerun after the subsequent test-only `Rows` cleanup adjustment and passed. - Scoped Makefile static checks for `./pkg/frontend ./pkg/embed` — PASS; molint/vet completed and pinned golangci-lint v2.14.0 reported 0 issues. `gofmt` and `git diff --check` — PASS. - The existing writable-stage BVT delta is unchanged from the independently reviewed b3a20 candidate; it passed normal comparison 124/124 twice with direct SQL/filesystem cleanup checks. Existing lifecycle focused/race-100 evidence also remains unchanged; this DATALINK delta adds no lifecycle mechanism. The standalone service build and BVT service binary predate the DATALINK production guard and are not claimed as exact-dd6ce binary evidence. This narrow delta was validated with the current CGo package builds and the exact embedded regression. No benchmark was run, so there is no benchmark-based performance claim. ### CI results All currently applicable CI has completed for the actual published head `dd6ce76d6a3246fdd941d8d6fad2caf610b3da38`: - [MatrixOne ALL CI](https://github.com/matrixorigin/matrixone/actions/runs/39740631529) — success. Required CI, shared build, UT x86, SCA arm64, UT coverage, Compose Proxy BVT, Standalone multi-CN pessimistic BVT, and coverage jobs passed. - [Connector/J Pool Reset E2E](https://github.com/matrixorigin/matrixone/actions/runs/39740631018) — success. - [Iceberg Connector E2E](https://github.com/matrixorigin/matrixone/actions/runs/39740630991) — workflow success; adapter module tidy passed. `Iceberg E2E Local` was skipped because the workflow currently sets `if: false`; this is not counted as a test pass. Other MatrixOne ALL CI jobs skipped by workflow configuration are reported as skipped, not passed. The earlier `ff321` CI failure is superseded and is not counted for this head. **Merge hold: DO NOT MERGE.** This task authorizes publication and CI monitoring, not merging. Keep #30704 and #30705 open; the references above are intentionally non-closing. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: XuPeng-SH <[email protected]>
What type of PR is this?
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.
All
ExportConfigmethod receiver names are consistent, resolving staticcheck ST1016 without changing cleanup behavior or suppressing diagnostics. Rebased ontomainat1362ffba70; the complete seven-file PR patch is byte-identical before and after this rebase. The linked ARM64 SCA job failed because its self-hosted runner lost communication, with no completed static-analysis diagnostic; fresh remote CI is required.Validation
-race -count=1: 2526 passed, with one existing skip in each mode.Test_vectorValueToJSONand JSON lifecycle regressions passed in the full frontend suites.doDumpQueryResultregression 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.go vet, configuredmolint, formatting and license-eye passed. Full affected-package configuredgolangci-lintreports 0 issues. License-eye checked all changed files (7 main / 11 release), 0 invalid; policy unchanged.gpt-6.1-sol/xhighdesign and final complete-PR review passed with no unresolved material blocker. Local results are distinct from remote CI.Latest rebase validation artifacts:
/home/xupeng/.codex/issue-to-pr/matrixone/30737/ci39623288409/(design.md,review.md, byte-identicalbefore.diff/after.diff, native build, normal/race/public SQL results, static logs and exit receipts). Earlier still-valid 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 is42-lint-comparison.json; retained stress/negative controls are in the adjacentreview-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.
Remote CI is pending for the updated revision.