Skip to content

event: account for raw rows in batch DML event size - #5960

Open
wlwilliamx wants to merge 1 commit into
pingcap:masterfrom
wlwilliamx:xwl/fix-batch-dml-event-size
Open

event: account for raw rows in batch DML event size#5960
wlwilliamx wants to merge 1 commit into
pingcap:masterfrom
wlwilliamx:xwl/fix-batch-dml-event-size

Conversation

@wlwilliamx

@wlwilliamx wlwilliamx commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

Issue Number: close #5959

Remote BatchDMLEvent instances keep their encoded row payload in RawRows
until the event collector calls AssembleRows. GetSize only accounted for
Rows, so dynamic stream memory control and byte-based batching treated the
remote row payload as zero bytes.

What is changed and how it works?

Make BatchDMLEvent.GetSize return the encoded RawRows length before rows
are assembled. After assembly, it continues to return the decoded chunk's
memory usage.

Extend the existing remote-row assembly unit test to verify size accounting
before serialization, after remote deserialization, and after row assembly.

Check List

Tests

  • Unit test
  • Manual test

Questions

Will it cause performance regression or break compatibility?

No compatibility impact. Remote batches may be split earlier when their actual
payload reaches the configured byte threshold, which is the intended behavior.

Do you need to update user documentation, design documentation or monitoring documentation?

No.

Release note

Fix dynamic stream memory and byte-batch accounting for remotely received DML batches.

Summary by CodeRabbit

  • Bug Fixes
    • Improved batch event size reporting when row data is stored in its encoded form.
    • Preserved accurate in-memory size reporting after row data is decoded and assembled.
  • Tests
    • Added coverage for size accounting before and after row data decoding.

Remote batch DML events retain their row payload in RawRows until the event collector handles them. Include that payload in GetSize so dynamic stream memory and byte batching account for it.
@ti-chi-bot ti-chi-bot Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 12, 2026
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5d3d8366-297a-4d2a-af5b-8f1af604e6c4

📥 Commits

Reviewing files that changed from the base of the PR and between 8bd1d7e and bfce542.

📒 Files selected for processing (2)
  • pkg/common/event/dml_event.go
  • pkg/common/event/dml_event_test.go

📝 Walkthrough

Walkthrough

BatchDMLEvent.GetSize now accounts for encoded RawRows when Rows is unavailable. Tests verify size reporting before unmarshalling, after unmarshalling, and after assembling decoded rows.

Changes

Remote Batch DML size accounting

Layer / File(s) Summary
Size fallback and validation
pkg/common/event/dml_event.go, pkg/common/event/dml_event_test.go
GetSize returns len(RawRows) when Rows is nil. Tests verify raw payload size before row assembly and decoded row memory usage after assembly.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: lidezhu

Poem

I’m a rabbit with rows in a stream,
Raw bytes now count in the size-meter dream.
Decode them, assemble with care,
The memory tally stays fair.
Hop, hop—the batch is precise!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change to account for raw rows in batch DML event size.
Description check ✅ Passed The description includes the issue reference, problem, implementation, unit tests, compatibility impact, documentation assessment, and release note.
Linked Issues check ✅ Passed The changes satisfy issue #5959 by including encoded RawRows in GetSize before remote rows are assembled and preserving decoded-row accounting afterward.
Out of Scope Changes check ✅ Passed The code and test changes remain limited to remote BatchDMLEvent size accounting and its unit-test coverage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@ti-chi-bot

ti-chi-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: asddongmen

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

The pull request process is described 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 needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Aug 12, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 12, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-08-12 09:10:51.269805559 +0000 UTC m=+3210437.305900616: ☑️ agreed by asddongmen.

@ti-chi-bot ti-chi-bot Bot added the approved label Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eventcollector: account for remote BatchDMLEvent row payload size

2 participants