fix: ReplicationPoller consumes slot if publication is not empty#1919
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts the Postgres CDC RLS replication poller lifecycle so it reacts to an empty/non-empty publication by pausing/resuming polling and dropping/recreating the replication slot as publication tables come and go, reducing unnecessary WAL work.
Changes:
- Add
Replications.drop_replication_slot/2and related tests. - Teach
ReplicationPollerto check publication table OIDs periodically and stop polling / drop the slot when the publication becomes empty, then resume when tables reappear. - Add unit + integration coverage for the poller’s empty-publication behavior and slot toggling.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/extensions/postgres_cdc_rls/replication_poller.ex | Adds publication OID tracking and slot drop/recreate behavior tied to publication emptiness. |
| lib/extensions/postgres_cdc_rls/replications.ex | Introduces drop_replication_slot/2 helper for removing logical replication slots. |
| test/realtime/extensions/cdc_rls/replication_poller_test.exs | Updates poller tests and adds coverage for “no tables → no polling” and toggling behavior. |
| test/realtime/extensions/cdc_rls/replications_test.exs | Adds unit tests for drop_replication_slot/2. |
| test/realtime/extensions/cdc_rls/cdc_rls_test.exs | Adds integration tests verifying slot toggling when publication/tables are changed. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
filipecabaco
approved these changes
May 28, 2026
leandrocp
reviewed
May 28, 2026
edgurgel
force-pushed
the
fix/replication-cdc-no-tables
branch
2 times, most recently
from
June 10, 2026 01:58
262d86b to
eae2a1c
Compare
filipecabaco
approved these changes
Jun 10, 2026
leandrocp
approved these changes
Jun 11, 2026
leandrocp
left a comment
Contributor
There was a problem hiding this comment.
Just 2 small suggestions, non-blocking.
Co-authored-by: Leandro Pereira <leandro@leandro.io>
We don't use the return
edgurgel
force-pushed
the
fix/replication-cdc-no-tables
branch
from
June 12, 2026 00:29
01eea67 to
3e6308c
Compare
This comment has been minimized.
This comment has been minimized.
|
🎉 This PR is included in version 2.107.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
What kind of change does this PR introduce?
The goal here is only to establish the replication slot when absolute necessary
Why do we even keep the ReplicationPoller up if there is no publication? If we don't whenever a postgres_changes join happens it will start it again. While this approach will leave this process up and running until it notices that there are no subscriptions (SubscriptionManager does this) and stop everything.
I've also fixed the case when fetching the publication tables could fail but we would assume that the publication was empty