Skip to content

fix(load): restore large CSV rows and preserve LOCAL upload errors - #31300

Merged
mergify[bot] merged 9 commits into
matrixorigin:mainfrom
aptend:fix/astra-30640-csv-restore
Oct 27, 2026
Merged

mergify[bot] merged 9 commits into
matrixorigin:mainfrom
aptend:fix/astra-30640-csv-restore

Conversation

@aptend

@aptend aptend commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #30640

What this PR does / why we need it:

CI BVT stability fix (test): vector_hnsw_delete_insert now waits for the HNSW serving view — a bounded wait_expect probing a real vector-index-scan result — before its exact assertions, and keeps probe + assertions inside one transaction so the proxy cannot migrate the session between probe and assertion (pkg/proxy doc.go rule 3 / tunnel.go inTxn gate).

Validation (local, 2-CN + PROXY topology; NOT the GitHub Docker Compose CI):

  • final patch with a binary built from the pre-rebase feature tip b817487937: 56/56, rc=0;
  • controls on a clean-main binary (2465dae): without the serving waits [constant-true metadata probe, no txn pin] -> failed 43/44 with EXPECT id 2001 / ACTUAL id 777; the same control with only the two serving wait probes re-added -> passed 52/52 (the only difference between these two runs is the presence of the serving waits);
  • separate negative control [txn pin present, constant-true metadata probe, no serving wait], also on the clean-main binary -> failed 47/48;
  • CI failures show the same EXPECT 2001 / ACTUAL 777 signature; the exact per-run migration path was not directly witnessed, so no causal claim is made.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify mergify Bot added the kind/bug Something isn't working label Oct 26, 2026
@matrix-meow matrix-meow added the size/XL Denotes a PR that changes [1000, 1999] lines label Oct 26, 2026
@aptend
aptend force-pushed the fix/astra-30640-csv-restore branch from 7a65752 to cf00a37 Compare October 26, 2026 13:40
@aptend
aptend force-pushed the fix/astra-30640-csv-restore branch from cf00a37 to 325ed6e Compare October 26, 2026 17:19
@matrix-meow matrix-meow added size/XXL Denotes a PR that changes 2000+ lines and removed size/XL Denotes a PR that changes [1000, 1999] lines labels Oct 27, 2026
@aptend
aptend requested a review from XuPeng-SH October 27, 2026 01:06
@XuPeng-SH

XuPeng-SH commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 12f2fb5cf5361bb5f58db67bc26b81dba258d817

Review completed. Read the assessment.

@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.

mo-bot review · mo-bot-local · review

Commit: 12f2fb5cf5361bb5f58db67bc26b81dba258d817

Assessment: approve

The complete nine-file review remains valid for the unchanged candidate. Admission, framing and cleanup stay with their existing owners. Both earlier findings are resolved: interrupted frames force retirement, and doubled quotes are fully charged. No actionable defect remains.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

Validation:

  • Attempt 3 verified unchanged sources, patch, behavioral contract, discussion and CI outcomes. Retained commands, source fingerprints, exit receipts and logs were audited; no product tests were repeated.

  • Exact-head evidence: isolation preflight and 192 native input hashes passed; parser package passed 149 RUN events; twelve lifecycle tests passed 779 individual race repetitions.

  • Verified 275 additional framing race repetitions against unchanged frontend semantics.

  • Frontend race execution recorded 7,406 passing events and no race reports, with one environment failure disclosed below.

  • Frozen current-head CI reports successful build, UT, coverage, static analysis and multi-CN BVT.

  • Parser benchmarks measured median overhead of 10.4% ordinary, 11.3% backslash-escaped, 12.4% doubled-quote and 2.8% empty-field workloads, with unchanged allocation counts.

  • Recovery audit passed. All six nonempty discussion items are assessed; the empty approval is recorded separately. Evidence and discussion assessments are saved under /home/xupeng/.local/state/mo-bot/jobs/1ea2afba5e73ad429ed93022/attempt-3. Source remained unchanged.

Limitations:

  • The full frontend race command exited 1 because unchanged Test_openNewFile_nilCtx attempted to write into the read-only checkout. This is an environment diagnostic, not a passing full-suite result or an introduced defect.

  • No fresh live large-file SQL restore or named multi-CN integration rerun; unverified author-only execution claims were excluded.

  • Benchmarks measure parser batches, not end-to-end throughput. The 64MiB record weight is not a heap-memory cap; failure draining can retain resources for up to 30 seconds.

  • The linked issue body was absent; the frozen PR contract and production callers established the reviewed requirements.

@mergify mergify Bot added the queued label Oct 27, 2026
@mergify

mergify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-27 02:33 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ❌ Checks failed · in-place
  • 🚫 Left the queue — 2026-10-27 03:31 UTC · at 1e8fe482c140b758232c7e6f4699ea631b18cc1c

This pull request spent 57 minutes 29 seconds in the queue, with no time running CI.

Reason

The merge conditions cannot be satisfied due to failing checks

  • CI Required

Failing checks:

Hint

You may have to fix your CI before adding the pull request to the queue again.
If you update this pull request, to fix the CI, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Requeued — the merge queue status continues in this comment ↓.

astra-30640 and others added 9 commits October 27, 2026 13:25
…ssue matrixorigin#30640)

- csvparser: configurable MaxRecordSize (default 64MiB via CN largest-entry-limit),
  counting raw content + 1 per framed field; fixes hidden per-fragment readUntil
  limit and misleading txn-entry-size-limit message
- frontend: interrupt in-flight load-local I/O on cancel and drain the finite
  client stream to protocol EOF so the statement error reaches the client on a
  reusable connection; bounded by per-read/total-wait/byte budgets

wip: authored by two prior writers; verification in progress
…atrixorigin#30640)

An ordinary (non-cancel) error surfacing through readThenWrite — e.g. the
parser retiring the pipe after rejecting an over-budget record mid-upload —
still returned early and let the cleanup defer disconnect the client (2013),
while the bind-change flavor already drained. Route it through the same
bounded drainOnExit drain so the SQL error answers on a reusable connection.
Adds TestProcessLoadLocalDrainsOrdinaryPipeErrorToEOF (focused+race green).
…ose owner/watcher ordering races (matrixorigin#30640)

- MysqlProtocolImpl now proxies InterruptLoadLocalIO / ClearLoadLocalIOInterrupt
  / ReadLoadLocalPacketWithTimeout to its Conn, so the production
  MysqlResp -> *MysqlProtocolImpl -> *Conn chain is drain-capable; a
  compile-time guard pins the contract. Previously every drain assertion on
  the real protocol failed, cancellation fell back to Disconnect, and the
  65MiB over-budget upload became 2013.
- The drain's total budget is now an absolute deadline installed on every
  network read of a packet, so one trickled header or payload can no longer
  outlive the total wait one byte at a time.
- A pending cancellation interrupt is serialized with every deadline install
  (loadLocalMu): the old check-then-arm window could no longer overwrite the
  interrupt and pin a silent read for the session timeout.
- processLoadLocal joins the cancellation watcher before lifting the
  interrupt and draining: a late InterruptLoadLocalIO can no longer retire a
  freshly armed drain (live matrixorigin#30640: drain killed 251us after the statement
  error -> 2013) or reach into the next command on a reused connection.
- Deterministic UTs (no sleeps/scheduling assumptions): the stroke gate pins
  join-before-clear; a gated net.Conn forces the exact arm window for header,
  partial-header and partial-payload silent reads; the real
  MysqlResp -> MysqlProtocolImpl -> Conn chain drains to protocol EOF and
  serves the next command.

Focused 12-name UT rc=0 and -race rc=0 (mo-cgo-test). Real mo-service binary:
65MiB over-budget upload returns ERROR 20301 (csv record size ... exceeds max
record size ...) on the same CONNECTION_ID, then SELECT 1 and a small LOAD
LOCAL succeed on that connection; no 2013/2006/packet/reconnect.
…tracts with failure-safe gates (matrixorigin#30640)

- interrupt gate parks the cancellation watcher between CloseWithError and
  the socket interrupt; one-shot release via sync.Once-backed cleanup so a
  Fatal path never leaves the watcher or arm goroutine parked.
- gatedReadDeadlineConn forces the check-then-arm window at the real
  SetReadDeadline boundary; interrupt execution is awaited through a barrier
  so side effects provably happened inside the window (RED evidence:
  red_fix8_b.log rc=1 with joinWatcher/arm-lock reverted, deterministic).
- owner/watcher test asserts the fixed order contract (join before clear,
  drain to protocol EOF, connection reusable).
- trickle drain budget restore is t.Cleanup-based.
…nc coordinator rebuilds

The multi-CN CI periodically deadlocked: the continuous ISCP executor's
mo_iscp_log job-state update transactions race the manual alter reindex
force_sync issued from the second coordinator CN, forming a lock cycle
on the shared job row. The embedded multi-CN fixture hosts the executor
on exactly one CN; discover that CN, pause its executor before the
manual rebuilds, and resume it only after the leftover subtest
transactions are rolled back and the SQL sessions are released (LIFO
cleanup ordering), keeping all cross-CN index/generation/rollback
assertions intact. Same quarantine shape as the temporary-table fixture
(matrixorigin#31288); production retry ownership is unchanged.

Fixes matrixorigin/matrixone CI instabilities seen on PR matrixorigin#31300 suite.
…oundary is unknown (matrixorigin#30640)

An interrupted LOAD DATA LOCAL upload read that consumed only part of a
frame (partial header, a complete header whose payload was never read, or
a partial payload) leaves the next unread byte off the packet boundary.
A drain starting a fresh packet read there can re-frame file bytes as the
empty upload EOF packet, falsely authorizing connection reuse and leaving
the frame remainder to be decoded as subsequent commands.

The connection now credits every consumed byte toward the frame — including
the (n > 0, err != nil) shape a single net.Conn Read may legally return —
and exposes a sticky LoadLocalFramingBroken state that neither an interrupt
clear nor connection teardown revives. MysqlProtocolImpl proxies the state
through the production chain. drainLoadLocalUpload refuses to resync when
the boundary is unknown, so the owner retires the connection; drains at a
clean boundary, the watcher join-before-interrupt-clear ordering and the
per-read/byte/wall drain budgets are unchanged.

Deterministic regressions drive partial-header and partial-payload
interrupts plus a single read that returns file bytes together with its
error through the real MysqlResp -> MysqlProtocolImpl -> Conn chain, and
pin both the retire decision and the safe-boundary reuse controls, with
failure-safe owner and watcher joins.
… the record bound (matrixorigin#30640)

A doubled quote inside a quoted field is two input bytes folding into one
decoded quote, but the parser appended only the folded byte to recordBuffer
and priced it at one: encoded content up to roughly twice the configured
limit bypassed the pre-unescaping whole-record weight (four doubled pairs
at 8 raw bytes passed MaxRecordSize=5).

The record now carries a per-record surcharge for consumed input bytes the
stored representation folded away — today the second byte of every
doubled-quote pair — and recordWeight prices stored representation plus
folded raw delta plus field framing, resetting with the other per-record
accumulators. Decoded values are untouched; the escaped-pair path already
charged both consumed bytes and is unchanged, as are delimiter and field-
framing semantics.

Regressions pin exact thresholds across block sizes 1/4/65536, escaped
parity, back-to-back in-budget records on one parser, shared multi-field
budgets including framing, and Reset reuse, all through the real parser
Read/Reset entry points.
After e941ab2 the plan always uses the HNSW scan for exact-ordered
reads, so the delta-checksum wait only proves ISCP published the model;
the CN serving the connection may still return the previous generation
(CI failures EXPECT 2001 / ACTUAL 777). Wait for the serving view itself
(boolean wait_expect probing the real vector index scan result), and keep
probe + assertions inside one transaction: the proxy refuses tunnel
migration while a transaction is open (pkg/proxy doc.go rule 3 /
tunnel.go inTxn gate), so the assertions cannot land on a CN that has
not loaded the generation.
@mergify

mergify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-27 06:23 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • ✅ Checks skipped · PR is already up-to-date
  • ✅ Merged — 2026-10-27 06:49 UTC · at 533e95796177d9eacdc909059ccf72b7ddd3ba5f · squash

This pull request spent 26 minutes 6 seconds in the queue, with no time running CI.

Required conditions to merge

This branch was previously deployed

1 inactive deployment
ci — 37631ef4 Deployed Oct 27, 2026 by aptend via Matrixone Coverage execution / Coverage #61513
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/test-ci size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants