Skip to content

fix(frontend): bound prepared long-data buffering - #29199

Merged
XuPeng-SH merged 7 commits into
matrixorigin:mainfrom
daviszhen:fix/issue-29187-long-data-memory
Sep 22, 2026
Merged

XuPeng-SH merged 7 commits into
matrixorigin:mainfrom
daviszhen:fix/issue-29187-long-data-memory

Conversation

@daviszhen

@daviszhen daviszhen commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • BUG

Which issue(s) this PR fixes:

Fixes #29187

What this PR does / why we need it:

Repeated COM_STMT_SEND_LONG_DATA chunks previously copied and retained every cumulative prefix in the parameter vector. Buffer each parameter in one statement-owned, geometrically growing off-heap MPool allocation and materialize it into the vector only once at EXECUTE.

Enforce the cumulative per-parameter max_allowed_packet limit. Since SEND_LONG_DATA has no response, latch failures and report them at EXECUTE; RESET/CLOSE clear the state. Release owned buffers on execution, reset, close, and error paths, and keep deferred failures as migration blockers.

Validation

  • Full frontend package: go test ./pkg/frontend -count=1 -timeout=10m (Linux/arm64 Docker).
  • Typecheck-tagged long-data tests passed.
  • Exact head 1bcb078e37c4d3f20d1d4e47153b11443bf5cdff: committed real-CN raw MySQL client regression in pkg/tests/issues/isolated/issue_29187_long_data_wire_test.go. Reproduce after building native dependencies: go test -p 2 ./pkg/tests/issues/isolated -run "^TestIssue29187LongDataWire$" -count=2 -timeout=10m -v. Linux/arm64 terminal result: both runs passed, each with two passes against the same live CN cluster; package ok in 27.603s. Each pass verifies exact 1024-byte streamed success, no unsolicited SEND response, 1025-byte cumulative rejection at EXECUTE for the correct statement, unaffected second statement, COM_STMT_RESET and successful same-connection reuse, COM_STMT_CLOSE, and clean connection quit. Focused allocator/close/deferred-error frontend tests passed with -count=5 at this head.
  • Raw protocol, 4 MiB in 64 chunks: staging RSS increase 22,476 KiB after the fix versus 401,908 KiB before it; returned value SHA-256 matches. These are single local runs, not a performance guarantee.
  • Raw protocol, 60 MiB in 3,840 chunks: staging RSS increase 360,960 KiB; EXECUTE with LENGTH(?) returned 60 MiB.

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

@daviszhen

Copy link
Copy Markdown
Contributor Author

CI diagnosis and fix at 4882965: both failed runs came from the newly merged standalone-shutdown regression test, not the long-data path. Attempt 1 timed out waiting 5s for the TN drain fault waiter; attempt 2 spent over 3 minutes waiting for embedded-cluster admission, so its 2-minute SQL context had already expired before SQL began. The test now starts fault injection and its SQL deadline after cluster startup, and allows 30s for the drain waiter (matching its other fault waits). Targeted Linux/arm64 coverage-mode test passed 3 consecutive runs. New PR CI is running.

@daviszhen

Copy link
Copy Markdown
Contributor Author

Updated this PR with the latest upstream/main; current head 79c9d52 is MERGEABLE. Re-ran the committed real-CN raw protocol regression at this exact head: go test -p 2 ./pkg/tests/issues/isolated -run ^TestIssue29187LongDataWire$ -count=1 -timeout=10m -v. PASS: TestIssue29187LongDataWire (13.76s), same-cluster-pass-1 (0.02s), same-cluster-pass-2 (0.00s), package ok (13.878s). The test checks exact 1024-byte success, 1025-byte cumulative rejection only at EXECUTE with no unsolicited SEND response, correct-statement error isolation, COM_STMT_RESET and successful same-connection reuse, COM_STMT_CLOSE, COM_QUIT, and a second pass on the same running cluster. The previously reported CMake/JDK HTTP 504 failures occurred in CI setup before project tests; the new head has fresh checks running.

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

GPT-6 Astra medium review: APPROVE. Reviewed the complete diff at exact head 79c9d52 against base 161fe8e. The single statement-owned geometric buffer closes cumulative-prefix retention while preserving ownership on allocation failure; execute/reset/close/error/migration paths release or report state correctly. Wire, focused lifecycle, allocator, deferred-error, migration-blocking, race-enabled Linux CI, and git diff check evidence were verified. No blocking functional, lifecycle, compatibility, or validation gap remains.

@mergify mergify Bot added the queued label Sep 22, 2026
@mergify

mergify Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-09-22 04:04 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-09-22 04:09 UTC · at 4f5a1f000e67563b9d22c70bfa38c221317df392

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

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

Reason

Pull request #29199 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

@XuPeng-SH
XuPeng-SH merged commit 170a559 into matrixorigin:main Sep 22, 2026
21 of 22 checks passed
@mergify mergify Bot added dequeued and removed queued labels Sep 22, 2026

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

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]: COM_STMT_SEND_LONG_DATA retains cumulative copies and amplifies one streamed parameter to multi-GiB CN memory

3 participants