Skip to content

Reduce retained CN logtail replay batch memory - #31574

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
jiangxinmeng1:fix/cn-logtail-replay-memory
Oct 28, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
jiangxinmeng1:fix/cn-logtail-replay-memory

Conversation

@jiangxinmeng1

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:

Related to #31350, specifically the CN logtail replay memory investigation. This does not claim to fix the issue's original oversized-WAL/DN-panic failure; those failures have not been shown to have the same cause.

What this PR does / why we need it:

PartitionState keeps one decoded logtail batch pointer per in-memory row. Previously, the retained insert batch also held RowID and commit-timestamp vectors even though each RowEntry already stores both values. Tombstone batches retained additional vectors although later readers need only the PK. If even one row from a batch remains live, these vectors remain live too.

This change clears the redundant insert vectors after replay, retains only the tombstone PK vector, and updates the affected read and size-accounting paths to use RowEntry.RowID/RowEntry.Time. It reuses the existing batch header and vector slice, so the optimized path introduces no additional per-batch allocations. It does not change the logtail wire format or persistent object format. Regression tests cover compact/legacy tombstone reads, in-memory insert reads, hidden RowID and statistics sizing.

Validation and performance:

  • On 10.222.1.55, the full pkg/vm/engine/disttae/logtailreplay and pkg/vm/engine/disttae test packages passed at the exact committed source diff. Test binaries were built locally and executed remotely; no tests were run locally for this final validation.
  • A remote single-row replay A-B-A microbenchmark found the same allocations as main: insert 2032 B/13 allocs, delete 2656 B/16 allocs. Median latency was approximately 1211 → 1276 ns/insert (+5.4%) and 1489 → 1544 ns/delete (+3.7%). The shared host had fluctuating I/O, so these are indicative microbenchmarks, not an end-to-end throughput guarantee.
  • An earlier 51 full-service baseline became resource-exhausted (3015) before a valid matched candidate run; it is not included as performance evidence. A controlled production-load A/B is still needed to quantify total memory savings and throughput on this exact revision.

@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 28, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: b3de9eb96ec1ae38e7a75c52935c17458a877d4c

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: b3de9eb96ec1ae38e7a75c52935c17458a877d4c

Assessment: approve

The scoped retention optimization preserves replay ownership, row identity/time, affected readers and logical size accounting. No actionable unresolved findings.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1586-7a01-9000-d45e20995cf8 · slot 1 · generation 1

Validation:

  • Reviewed all 11 changed files, affected consumers, publication and cleanup paths, both discussion entries, and linked issue context.

  • Static checks passed for frozen-source identity, patch consistency, whitespace, Go formatting and discussion coverage. Receipt: checks/1793189785666549231-4.json; retained log: static-review-check.log.

  • Reused supplied current-head CI results reporting successful build, UT, SCA, coverage and multi-CN BVT checks. Skipped checks were not counted as passes.

  • Saved review-plan.md, review-evidence.md, discussion-assessment.json and validation-evidence.json; source remained unchanged.

Limitations:

  • No local Go, SQL, race or performance tests were run. Raw author test/benchmark receipts and CI per-test logs were not supplied.

  • Production memory savings and throughput remain unquantified. This approval does not establish resolution of the linked issue's separate oversized-WAL/DN-panic failure.

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

mergify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue

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

So far

  • ✅ Entered the queue Wed 28 Oct, 12:19 · rule main · triggered by rule Automatic queue on approval for main
  • ⏹️ Testing stopped · in place
  • 🚫 Left the queue 12:52 · 0c649ad

Reason

Pull request #31574 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.

Merge conditions: 2 of 3 met

This pull request

Condition Required by
✅ #review-threads-unresolved = 0 GitHub branch protection
✅ github-review-approved GitHub branch protection

The batch, tested in place

Condition Required by
❌ any of: check-neutral = CI Required, check-skipped = CI Required, check-success = CI Required GitHub branch protection

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 4808a7b into matrixorigin:main Oct 28, 2026
26 of 27 checks passed
@mergify mergify Bot added dequeued and removed queued labels Oct 28, 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

dequeued kind/enhancement size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants