Skip to content

fix: fail dump exports on source row iteration errors - #57

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
ck89119:issue-30574-main
Oct 22, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
ck89119:issue-30574-main

Conversation

@ck89119

@ck89119 ck89119 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes matrixorigin/matrixone#30574.

SQL export treated Rows.Next() == false as normal EOF without checking Rows.Err(). Canceling the source query could therefore produce a truncated dump, exit 0, and append MODUMP SUCCESS.

  • Propagate row-iteration errors from SQL and CSV export.
  • Reserve an exclusive query connection. On failure, close the physical MySQL connection before closing unread rows, so cleanup cannot wait for the source to send EOF. Successful exports return the healthy connection to the pool.
  • Preserve bounded pre-result ErrBadConn retries: release the failed reservation and reacquire a connection, for at most three query attempts. Never retry after receiving a result set.
  • Reset and return both SQL buffers on success and failure.
  • Add deterministic tests for normal EOF, empty results, chunk boundaries, cancellation, read/scan errors, cleanup, and actual CLI exit status/success markers.

Already-emitted partial output is not rolled back; an interrupted export now fails instead of certifying that output as complete. This does not change cross-table snapshot behavior.

Validation

On macOS arm64, using Go 1.23.0 and this checkout's native build:

  • Merged mo/main at 0ed6f92, preserving CSV fixes from fix: csv dump corrupts literal \N and NULL text values (matrixorigin/matrixone#30568) #63, BIT encoding from fix: encode BIT dump values as hexadecimal SQL literals #54, and the oversized-row INSERT-header fix from fix: drop unflushed INSERT header for oversized rows in SQL dump mode #62. Their regression tests and the full package pass in normal and race modes.
  • Focused regression tests pass, including subprocess exit-code tests; they reproduce the failure before the fix.
  • CSV completion tests verify that source iteration errors are checked before the final buffered Flush, and that a Flush failure at normal EOF is propagated.
  • A real MySQL-driver protocol fixture deliberately never sends the result-set EOF. CSV creation and SQL output failures return the original error, close the socket, and discard the connection without waiting for the source. The successful EOF control verifies reuse via PING on the same connection. The two early-failure cases reproduce Rows.Close → readUntilEOF blocking on cde3588.
  • A deterministic connector regression reproduces the missing retry on 8b7d882. It checks recovery after one/two bad connections, wrapped errors, the three-attempt limit, physical connection replacement/cleanup, unchanged SQL, and exact output. Non-retryable query errors and row-iteration errors (including ErrBadConn) are not retried.
  • The retry-boundary regression passes 100 repetitions under -race. go vet, incremental configured lint, formatting, and make build pass.
  • Changed-block statement coverage against the updated base: 100%; affected functions: 85.7–97.6%.
  • Real KILL QUERY A/B on an isolated single LOG/TN/CN instance, after INSERT output starts and the source SELECT is confirmed active (evidence from 8b7d882, reused for its normal-sized INT/VARCHAR workload, which does not reach the merged BIT/oversized-row changes):
    • Original: exit 0, success marker present.
    • Fixed: exit 1, context canceled, no success marker.
  • An uninterrupted fixed export restores all 200,000 rows; SUM(id)=20000100000 and total payload length is 40,000,000 bytes. Test databases and the test-owned service were cleaned up.

The integration server binary was built at MatrixOne 9dfe5c1be9, not the issue's original server revision. No remote CI result is claimed from these local checks.

@ck89119
ck89119 marked this pull request as ready for review October 20, 2026 03:27
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T10:53:29.633977Z 8b2000c Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@mergify

mergify Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8b7d882e26

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cmd/mo-dump/main.go Resolved
@ck89119

ck89119 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 8b2000cba9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ck89119

ck89119 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 8b2000cba9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE at 8b2000c (base 324c33d).

Complete production/test review found no remaining material blocker. Row iteration errors reach the CLI failure path; cleanup owns the reserved connection, closes the physical MySQL socket before unread rows can drain, and returns healthy connections normally. Pre-result ErrBadConn retries are bounded and never extend across a returned result set. Both buffers reset/return on every exit. The connection reservation is limited to the ownership boundary that needs independent failure cleanup.

The earlier bad-reserved-connection review comment is fixed and resolved. Deterministic connector tests and the real-driver protocol fixture prove separate contracts; the fixture never supplies EOF to rescue the failure path. Both exact tests pass 100 repetitions under race. Owning-package normal/race runs each have 52 passing test/subtest events, with only the two independently base-confirmed CSV assertion failures. Build/vet/gofmt/diff checks pass. Existing author KILL QUERY evidence remains applicable to the unchanged post-result path; this review does not claim it was rerun on latest main.

Merge coordination with #63 is required: preserve both Rows.Err() propagation and the new buffered CSV writer's final Flush() error. Their current main.go/main_test.go merge conflicts need semantic resolution and combined tests. This approval is for this exact head. No subagents or source edits.

@XuPeng-SH
XuPeng-SH merged commit 2384b16 into matrixorigin:main Oct 22, 2026
@ck89119
ck89119 deleted the issue-30574-main branch October 22, 2026 07:03
aptend added a commit that referenced this pull request Oct 22, 2026
…trip-305xx

Resolve cmd/mo-dump/main.go conflicts against main's bufio-based CSV writer
(#57/#59) and the #30638 INSERT-header fix (#62), and
harden the #30587 sql_mode pin:

- imports: keep strconv/math for the float overflow/-0 CAST path (#30598);
  main's regexp/encoding-csv removals retained.
- toCsv tail: take main's r.Err()+w.Flush(), which already covers the #30628
  final-flush error; drop the csvWriter.Error() alternative.
- showLoad: keep plain-name CSV reference (#30481), sqlStringLiteral quoting
  of path/delimiter (#30590) and the explicit Close() error check (#30628).
- sql_mode pin (#30587): emit once at the top of the script instead of inside
  the per-database all-tables block. A multi-database dump previously
  overwrote @MODUMP_SAVED_SQL_MODE with the already-stripped mode, so the
  end-of-script restore restored the wrong value; -tbl dumps skipped the pin
  entirely.
- sql_mode strip: remove NO_BACKSLASH_ESCAPES from a comma-wrapped list via
  TRIM(BOTH ',' FROM REPLACE(CONCAT(',',mode,','),',NO_BACKSLASH_ESCAPES,',','))
  so it cannot leave an invalid empty token ('X,' / ',X' / 'X,,Y') at any
  position of the mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: mo-dump reports success after export query is canceled and silently omits rows

2 participants