Skip to content

server: limit accumulated COM_STMT_SEND_LONG_DATA size (release-8.1-20260724-v8.1.2) (#69694) - #70170

Open
bb7133 wants to merge 1 commit into
release-8.1-20260724-v8.1.2from
cp-69694-8.1-v8.1.2
Open

server: limit accumulated COM_STMT_SEND_LONG_DATA size (release-8.1-20260724-v8.1.2) (#69694)#70170
bb7133 wants to merge 1 commit into
release-8.1-20260724-v8.1.2from
cp-69694-8.1-v8.1.2

Conversation

@bb7133

@bb7133 bb7133 commented Jul 28, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

Issue Number: close #69693

Problem Summary:
Cherry-pick #69694 (limit accumulated COM_STMT_SEND_LONG_DATA size) to release-8.1-20260724-v8.1.2.

What changed and how does it work?

Cherry-pick of ed2376a. One trivial conflict in the import block of pkg/server/conn_stmt_test.go (dropped the master-only pkg/planner/core/resolve import, unused on this branch). go vet ./pkg/server/ passes. See #69694 for the full description.

Check List

Tests

  • Unit test

Release note

TiDB now limits the accumulated `COM_STMT_SEND_LONG_DATA` size for a prepared statement by `max_allowed_packet`.

Summary by CodeRabbit

  • Bug Fixes
    • Added validation for oversized statement long-data payloads before execution.
    • Prevented long-data buffers from growing beyond the configured maximum packet size.
    • Prepared statements now return an appropriate packet-size error and clear affected bound parameters after an oversized payload is detected.
    • Added safeguards to ensure statements can be reused normally after the error.

@ti-chi-bot ti-chi-bot Bot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Jul 28, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mjonss for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 28, 2026
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e8b8397d-9784-4487-a7b2-d0679c7fbc8a

📥 Commits

Reviewing files that changed from the base of the PR and between 80db670 and 4b0c0f3.

📒 Files selected for processing (4)
  • pkg/server/conn_stmt.go
  • pkg/server/conn_stmt_test.go
  • pkg/server/driver.go
  • pkg/server/driver_tidb.go

📝 Walkthrough

Walkthrough

Prepared statements now limit accumulated long data by MaxAllowedPacket, validate the limit before binary parameter parsing, and reset oversized-data state after errors. Tests cover long-data submission, execution failure, cleanup, and subsequent validation.

Changes

Long-data packet limit

Layer / File(s) Summary
Long-data accumulation and validation
pkg/server/driver.go, pkg/server/driver_tidb.go
PreparedStatement exposes CheckLongDataSize; TiDBStatement bounds long-data accumulation, reports ErrNetPacketTooLarge, and resets its tracking flag.
Execute-time validation gate
pkg/server/conn_stmt.go
handleStmtExecute checks long-data size before parsing binary parameters.
Max-packet execution coverage
pkg/server/conn_stmt_test.go
Tests verify oversized long-data execution errors, bound-parameter cleanup, and post-error validation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • pingcap/tidb#70083: Adds the same prepared-statement long-data validation, execution gate, and max-packet test path.

Poem

A bunny guards each packet’s size,
No endless bytes can overflow the wise.
Long data hops through checks in line,
Too-large bundles earn an error sign.
Reset, then safely bound anew—
Hop, hop, the statement knows what to do!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main change: limiting accumulated COM_STMT_SEND_LONG_DATA size.
Description check ✅ Passed The description covers the issue, problem summary, implementation details, tests, and release note.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cp-69694-8.1-v8.1.2

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 21 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-8.1-20260724-v8.1.2@80db670). Learn more about missing BASE report.

Additional details and impacted files
@@                       Coverage Diff                        @@
##             release-8.1-20260724-v8.1.2     #70170   +/-   ##
================================================================
  Coverage                               ?   37.0245%           
================================================================
  Files                                  ?       1505           
  Lines                                  ?     576266           
  Branches                               ?          0           
================================================================
  Hits                                   ?     213360           
  Misses                                 ?     341576           
  Partials                               ?      21330           
Flag Coverage Δ
integration 37.0245% <0.0000%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling ∅ <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 23.9830% <0.0000%> (?)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ti-chi-bot

ti-chi-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

@bb7133: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/unit-test 4b0c0f3 link true /test unit-test
idc-jenkins-ci-tidb/mysql-test 4b0c0f3 link true /test mysql-test

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant