Skip to content

Pace replication intake without releasing slot ownership - #14

Draft
olivermt wants to merge 1 commit into
baselabs:mainfrom
olivermt:fix/cdc-backpressure
Draft

olivermt wants to merge 1 commit into
baselabs:mainfrom
olivermt:fix/cdc-backpressure

Conversation

@olivermt

Copy link
Copy Markdown

WAL-position distance can grow because of unrelated writes or segment switches, even when Replicant has little queued data. A slow sink currently trips a permanent halt instead of allowing the stream to catch up.

This uses the pause/resume API merged in elixir-ecto/postgrex#799 to pace intake by queued payload bytes and message count while retaining the connection and slot. Feedback continues while paused, and processing credits remain separate from durable acknowledgements.

Retained transactions and batches have their own budget: spill or flush where possible, otherwise halt on actual exhaustion. Incremental snapshot pacing uses retained data rather than WAL distance. The port preserves current decoder support and includes coverage for multi-message wal2json payloads.

Submitting this as a draft until Postgrex has a release containing the pause/resume API. Once that lands, I will update the dependency, force-push the branch, and mark this PR ready for review.

This code has been running in prod for a month or so now with no issues.
Originally bumped into the problem after an importer flushed a couple of thousand rows in one write and the replicator fell over.

@olivermt
olivermt marked this pull request as draft October 22, 2026 12:39
@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 28b8ec0a-09d7-44f9-8203-b5032b25bb4e
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@olivermt

Copy link
Copy Markdown
Author

I have put the pr in draft mode until postgrex has a release btw. Created it as a full pr by accident :)

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