Skip to content

logpuller: spill realtime large transaction prewrites#2

Draft
asddongmen wants to merge 2 commits into
0626-split-big-txnfrom
log-puller-big-txn-optimize
Draft

logpuller: spill realtime large transaction prewrites#2
asddongmen wants to merge 2 commits into
0626-split-big-txnfrom
log-puller-big-txn-optimize

Conversation

@asddongmen

@asddongmen asddongmen commented Jul 7, 2026

Copy link
Copy Markdown
Owner

What problem does this PR solve?

Issue Number: ref pingcap#5561

This is stacked on 0626-split-big-txn. Realtime large transactions can retain large PREWRITE Value / OldValue payloads in logpuller matcher before eventstore processing, and stale COMMIT rows could temporarily attach values that are dropped immediately.

What is changed and how it works?

  • Skip value attachment for stale COMMIT rows while still matching and removing their prewrite cache entries.
  • Store compact matcher prewrite metadata and use the shared pkg/spill record-file utility from the base branch to spill unmatched prewrite payloads after a 1 MiB per-matcher in-memory threshold is exceeded.
  • Read spilled payloads back only for normal COMMIT matching; stale COMMIT and rollback clean metadata without readback.
  • Flush large logpuller KV event batches in bounded chunks, clear transferred protobuf row payloads, and add backpressure for large region events.

Check List

Tests

  • Unit test
  • Manual test on dev machine

Manual test details

Before splitting the shared spill commit into the base branch, equivalent code at commit 353d65779 was patched to root@10.2.15.7 and one 20GB transaction was run through changefeed logpuller-thr-20g-131911.

Result:

  • upstream rows: 20971520
  • downstream rows: 20971520
  • changefeed state: normal
  • checkpoint time: 2026-07-07 13:43:37.141
  • kernel OOM lines since run start: 0
  • peak observed spill: about 640 files and 21.1 GB
  • observed CDC RSS during spill: about 8-9 GB

After the branch split, log-puller-big-txn-optimize contains only logpuller changes relative to 0626-split-big-txn.

Questions

Will it cause performance regression or break compatibility?

No compatibility change expected. The spill path trades disk IO for bounded matcher heap usage only when unmatched prewrite payloads exceed the per-matcher threshold.

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

No.

Release note

Reduce TiCDC logpuller memory usage for realtime large transactions by spilling unmatched prewrite payloads to disk.

@asddongmen
asddongmen force-pushed the log-puller-big-txn-optimize branch 5 times, most recently from b2a475f to 353d657 Compare July 7, 2026 05:17
Avoid attaching cached prewrite Value and OldValue to COMMIT rows that are already stale for the subscribed span. Cached stale COMMIT rows are still matched and removed during initialization, but dropped without retaining large payloads.
Spill unmatched prewrite values once the matcher crosses the memory threshold.

Flush matched KV event cache in bounded chunks during large COMMIT batches while preserving the final async wake path.

Clear protobuf row value references after the matcher or KV cache takes ownership, and force GC after releasing large intermediate chunks.

Apply backpressure from large dynstream entry events back to the TiKV receive loop so COMMIT value batches cannot accumulate in the puller buffer while the handler is waiting on eventstore writes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant