Add memory limit for buffered repl changes#826
Merged
Conversation
# Conflicts: # pkg/repl/subscription_buffered_test.go
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a per-subscription “soft” memory cap to buffered replication subscriptions to prevent wide-row workloads from growing the in-memory buffer without bound, and updates client locking to avoid deadlocks when backpressure causes HasChanged to block.
Changes:
- Track approximate buffered bytes per subscription and apply backpressure by parking
HasChangedon a condition variable once the soft limit is reached. - Make the per-subscription soft limit configurable via
ClientConfig.SubscriptionSoftLimitBytes(default 256 MiB; negative disables). - Adjust client lock usage around subscription dispatch (and DDL matching) to avoid deadlocks when
HasChangedparks.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/repl/subscription_buffered.go | Adds byte accounting, soft-limit backpressure via sync.Cond, and logs/counters for parking. |
| pkg/repl/subscription_buffered_test.go | Initializes cond in existing tests and adds new unit/integration tests for accounting + park/wake behavior and deadlock regression. |
| pkg/repl/README.md | Documents the new memory backpressure behavior and operational implications. |
| pkg/repl/client.go | Introduces default/configured soft limit, wires cond during subscription construction, and releases c.Lock before calling HasChanged. |
| pkg/repl/client_test.go | Updates tests to initialize cond for manually constructed subscriptions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
aparajon
approved these changes
May 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A Pull Request should be associated with an Issue.
Fixes #822