Skip to content

fix(frontend): preserve LOCAL upload framing on KILL QUERY - #31703

Merged
XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/issue-31475-kill-local
Oct 29, 2026
Merged

XuPeng-SH merged 5 commits into
matrixorigin:mainfrom
iamlinjunhong:codex/issue-31475-kill-local

Conversation

@iamlinjunhong

@iamlinjunhong iamlinjunhong commented Oct 29, 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:

Fixes #31475 (includes the active-session KILL coverage consolidated from #31278).

What this PR does / why we need it:

KILL QUERY during a finite LOAD DATA LOCAL upload could still disconnect the client after #31300: a socket interrupt discarded partial packet progress, so the drain could not safely find the actual upload EOF. Preserve header/payload progress under the upload owner's control and discard exactly the interrupted frame before draining subsequent packets. The client receives 1317/70100, the LOAD statement rolls back, and the original connection remains usable.

The discard path keeps the existing silent-read, total-time and byte limits, checks the remaining packet against its byte budget before reading or allocating, and uses at most 32 KiB of new reusable scratch. Fatal framing/transport errors and stalled or over-budget streams still retire the connection. Bytes inside a payload cannot masquerade as upload EOF or commands. The cancellation watcher remains joined before deadline clearing and connection reuse.

Extend the existing lightweight protocol fixture and shared one-CN SQL integration fixture. Deterministic barriers exercise cancellation after a complete header and after LOAD execution but before transaction finalization. Tests assert exact 1317/70100, rollback, unchanged connection ID across successive LOAD cancellations, preservation of the prior statement in an explicit transaction, KILL CONNECTION behavior, successful completed LOAD/idle KILL, and ordinary SLEEP cancellation. Existing malformed-tail, timeout, byte-bound and cleanup oracles are retained.

Validation

  • Pre-fix reproduction: five interrupted header/payload offsets disconnect; the synchronized real SQL baseline also disconnects during upload. The corrected implementation preserves the same connection and rolls back.
  • Full ./pkg/frontend normal and race runs pass using .agents/skills/mo-dev/scripts/mo-cgo-test.
  • Full ./pkg/tests/sqlintegration normal run passes; the corrected TestKillLoadLocal root also passes after the review's explicit-transaction barrier correction.
  • Focused adaptive race repetitions pass for all 16 affected lifecycle tests, with each exact root selected separately and repetitions derived from a 30-second budget (5–100 runs).
  • gofmt, git diff --check, go vet and incremental golangci-lint pass for the changed package closure.
  • Independent gpt-6-astra medium design and integrated final review completed; the review's deterministic-test finding was corrected and revalidated.

CI repair validation — 276763b

The Linux/arm64 SCA failure, attempt 1 was reproduced with CI-pinned molint 35bd4d9a4055: DiscardLoadLocalPacket introduced an unapproved recover. Route the synchronous discard through the existing approved ExecuteFuncWithRecover; errors and panics still invalidate framing and prevent further drain/read reuse. No analyzer suppression or tool-version change.

New validation on darwin/arm64, Go 1.27.1:

  • .agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=300s ./pkg/frontend and the same command with -race: both pass.
  • Focused panic regression (header, allocation, payload), existing interrupted-frame, data-plus-error, byte-budget and read-error tests pass. TestProcessLoadLocalResumesInterruptedFrame also passes 100 adaptive race repetitions after one measured run.
  • CI-pinned molint check -mod=readonly ./pkg/frontend ./pkg/tests/sqlintegration, go vet for the same packages, incremental golangci-lint (0 issues), gofmt, diff checks and the delivery artifact check pass.

The unchanged SQL integration evidence above is reused; this correction changes only the panic recovery boundary. The full Linux SCA result remains pending new CI.

All results above are local darwin/arm64, Go 1.27.1 evidence. GitHub CI is pending.

Scope

The historical unknown-ID and silent-success variants did not reproduce when KILL targeted a known active session at synchronized upload/finalization boundaries on current main. The regression test explicitly rejects both outcomes; no speculative connection-map, routing or transaction rewrite is included. Multi-CN routing is unchanged. Connection reuse remains bounded by the existing upload-drain limits.

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

@XuPeng-SH

XuPeng-SH commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 276763b2c99662370cec9fe0a35be9ad7f19acf8

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: 276763b2c99662370cec9fe0a35be9ad7f19acf8

Assessment: approve

The fix preserves interrupted LOCAL packet framing while retaining bounded draining, fatal-error retirement and watcher synchronization. Regression tests cover connection reuse, rollback and relevant failure paths. No actionable findings remain.

Model: gpt-6-astra / xhigh

Session: 01a1869d-999c-7481-b340-ae4a63e8cee4 · slot 1 · generation 2

Validation:

  • Reviewed the complete delta, both linked issues, all discussion entries, and affected protocol, cancellation and transaction owners.

  • Local scope, clean-source, patch, gofmt and whitespace checks passed; retained static-check.log and receipt checks/1793274081409919317-2.json.

  • Reused supplied successful Linux UT, arm64 SCA and both BVT-group results, supported by the author's reported frontend normal/race and SQL integration validation.

  • Saved review-plan.md and discussion-assessment.json.

Limitations:

  • No local Go or SQL tests were rerun. Raw author and CI test logs were not supplied; execution results remain attributed to the supplied evidence.

  • Connection preservation remains subject to the existing drain timeout and byte limits.

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

mergify Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue

58 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Thu 29 Oct, 11:43 · rule main · triggered by rule Automatic queue on approval for main
  • ⏹️ Testing stopped · in place
  • 🚫 Left the queue 12:41 · 254e27b

Reason

Pull request #31703 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, 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.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

Times in UTC · dashboard · how the merge queue works

@XuPeng-SH
XuPeng-SH merged commit 1ce112f into matrixorigin:main Oct 29, 2026
28 of 29 checks passed
@mergify mergify Bot added dequeued and removed queued labels Oct 29, 2026
XuPeng-SH added a commit that referenced this pull request Nov 22, 2026
)

## What type of PR is this?

- [x] BUG
- [x] Test and CI

## Which issue(s) this PR fixes:

Related to #31475 and #31703. The failing coverage test was observed on
#32914.

## What this PR does / why we need it:

When KILL QUERY interrupted a `LOAD DATA LOCAL` upload, closing the pipe
reader caused the SQL consumer to see `io.ErrClosedPipe`. The client
could receive MySQL error 1105 for the interrupted query.

Close the upload pipe writer with the cancellation error so the consumer
receives it and the existing protocol mapping returns MySQL error 1317 /
SQLSTATE 70100. The upload owner still drains a finite client stream
before the session is reused. The regression captures the consumer error
while the finite tail is pending and checks it after the upload owner
has joined.

## Validation

- The deterministic pipe regression returned `io.ErrClosedPipe` on clean
main at `96d0d01872`.
- The full frontend package passed with the race detector in short mode.
All seven `TestKillLoadLocal` wire scenarios passed under race and 12
times each with coverage enabled.
- The focused pipe regression and the partial-payload wire scenario also
passed 100 race repetitions each on the identical fix.
- Formatting, diff checks, err-check, vet, golangci-lint and molint
passed for the affected scope.

Signed-off-by: XuPeng-SH <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

This branch was previously deployed

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

Labels

dequeued kind/bug Something isn't working size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: KILL QUERY during in-flight LOAD DATA LOCAL severs the connection, no-ops, or returns Unknown connection id

3 participants