Skip to content

[Postgres] Fix slot recovery & improve log output #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 12, 2024
Merged

Conversation

rkistner
Copy link
Contributor

Fixes regression from #150.

When starting replication, there are 4 different scenarios we cater for, depending on whether or not we have already completed the initial snapshot before, and whether or not we have a working logical replication slot.

1. haveSnapshot: false, haveWorkingSlot: false -> initial sync from scratch
2. haveSnapshot: true,  haveWorkingSlot: true  -> resume streaming replication
3. haveSnapshot: false, haveWorkingSlot: true  -> resume initial sync (new in #150)
4. haveSnapshot: true,  haveWorkingSlot: false -> initial sync from scratch (broken in #150)

The regression was in case 4 above - the slot would not get re-created, and replication would remain stuck. It can be triggered by something like replication lag falling too far behind, or anything else that makes the replication slot invalid.

The fix here is to raise a MissingReplicationSlotError error again for that case. That is caught higher up in the process, creates a new replication slot with an incremented index (while keeping the current data active), and then replicating with that new slot.

This PR also makes minor improvements to log output.

Copy link

changeset-bot bot commented Dec 11, 2024

🦋 Changeset detected

Latest commit: 7bfecb9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@powersync/service-module-postgres Patch
@powersync/service-core Patch
@powersync/service-image Patch
@powersync/service-module-mongodb Patch
@powersync/service-module-mysql Patch
test-client Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@rkistner rkistner changed the title [Postgres] Fix slot recovery [Postgres] Fix slot recovery & improve log output Dec 11, 2024
@rkistner rkistner marked this pull request as ready for review December 11, 2024 16:45
@rkistner rkistner merged commit e3a9343 into main Dec 12, 2024
15 checks passed
@rkistner rkistner deleted the fix-slot-recovery branch December 12, 2024 08:51
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.

2 participants