Skip to content

fix(disttae): tie insert logtail buffers to snapshot lifetime - #33128

Merged
XuPeng-SH merged 2 commits into
mainfrom
fix/logtail-replay-vector-lifetime-33118
Nov 24, 2026
Merged

XuPeng-SH merged 2 commits into
mainfrom
fix/logtail-replay-vector-lifetime-33118

Conversation

@LeftHandCold

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • BUG

Which issue(s) this PR fixes

Fixes #33118. Regression introduced by #33052.

What changed

Insert replay passed the engine mpool to protobuf decoding. This copied column data/area into native vectors, but retiring a row removes the row and index entries without owning the last reference to that batch. Multiple partition snapshots may still read it. Consequently, freeing on row removal would be unsafe; leaving the copy as-is leaks it.

Use a read-only view of the received logtail instead: the client unmarshals each response into fresh Go buffers, and a snapshot keeps exactly the referenced buffers alive. Direct/local insert callers (notably catalog bootstrap) can supply a protobuf view over mutable engine vectors, so detach those inputs on the Go heap when retaining row data. Both entry points use the same replay implementation. No per-row release, finalizer, background task, or wire/SQL format change.

Validation

  • Same test on unchanged main 07d7baa32a: after actual object retirement the replay pool retained 67 B (received), 67 B (local), and 103 B (keys-only). The fix returns all three to zero and an older snapshot still returns the original key and out-of-line varchar.
  • Negative control: merely changing the original decoder argument to nil clears the pool but makes the local snapshot return key 0 after its source is overwritten (expected 42).
  • Full logtailreplay package passes both normal and race builds. The exact regression test also passes 100 consecutive repetitions under -race. Real TAE TestClusterByRealLogtailIntegration passes; its allocator ends at its initial balance. Package vet and the configured incremental SCA (molint and golangci-lint) pass.
  • Live-entry microbenchmark, same base/fix entry point, 5,000 iterations: 16 → 13 Go allocs/op. This is not an end-to-end throughput claim.

The historical TKE run is the operational witness, not a run of this patch. A post-merge Weekly should check the native replay stack and the AP restart count during no-PK bulk insert.

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

@mergify

mergify Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Queue requested — the merge queue status continues in this comment ↓.

@XuPeng-SH

XuPeng-SH commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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

Commit: 197a9443e5c35251312339fabb40dd259ac1d880

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: 197a9443e5c35251312339fabb40dd259ac1d880

Assessment: approve

Insert replay now lets snapshot references govern the lifetime of decoded logtail buffers. Local callers copy mutable inputs when replay retains row data, and both paths share the same replay implementation. The regression test verified that retirement leaves the replay pool at zero while an older snapshot can still read the original values.

Model: gpt-6.2-sol / xhigh

Session: 01a20682-9189-75a0-839a-f36d8b2372a5 · slot 1 · generation 3

Validation:

  • Verified the frozen patch, pinned policy, native build inputs, and isolated test runtime.

  • The logtailreplay package passed under the race detector. All 100 repetitions of the lifetime regression passed for received, local, and keys-only inserts. See checks/1795495436053310016-2.json and checks/1795495470504565352-2.json.

  • TestClusterByRealLogtailIntegration passed under the race detector. The TAE allocator started and ended at zero bytes. See checks/1795495484292538891-2.json.

Limitations:

  • The historical TKE OOM attribution and benchmark figures rely on supplied reports.

  • One existing tombstone test skipped because its fixture requires real tombstone object files.

@mergify mergify Bot added the queued label Nov 24, 2026
@mergify

mergify Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

❌ Left the queue · Matrixone Coverage execution / Coverage fails with this pull request

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

So far

  • ✅ Entered the queue Tue 24 Nov, 04:46 · rule main · triggered by rule Automatic queue on approval for main
  • ❌ Checks failed · in place
  • 🚫 Left the queue 05:40 · d806f6c

The failure is in this pull request. It failed tested alone on top of main.

Reason

The merge conditions cannot be satisfied due to failing checks

Failing checks:

To get back in the queue

  • Push a fix: the pull request is queued again once its queue conditions match.
  • If the failure is a flake, tick the box below to queue it again as it is.

Merge conditions not met when it left the queue

  • any of · required by GitHub branch protection:
    • check-neutral = CI Required
    • check-skipped = CI Required
    • check-success = CI Required

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

  • Requeue this pull request
2 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub branch protection
  • github-review-approved · required by GitHub branch protection

Times in UTC · dashboard · how the merge queue works

This branch was successfully deployed

No deployments
ci — d806f6cd Deployed Nov 24, 2026 by mergify[bot]
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/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: AP CN native memory grows after Family AP workloads and reaches OOM limit

3 participants