Skip to content
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

feat (sync-service)!: clean all shapes when switching to a different DB #1703

Merged
merged 4 commits into from
Sep 16, 2024

Conversation

kevin-dp
Copy link
Contributor

@kevin-dp kevin-dp commented Sep 16, 2024

Fixes #1689.
This PR uses Postgres' system_identifier to detect when Electric is connected to a different Postgres database than before. When that is the case, we log a warning and clean all shapes. Cleaning all shapes is consistent with how we handle Point In Time Recoveries (where we also clean all shapes).

Note: this is a breaking change because we modify the structure of the timeline we store persistently. We used to just store the timeline ID, but now we store a list [pg_id, timeline_id] so we can't read out old persisted timeline information as we are expecting the new structure.

Copy link
Contributor

@robacourt robacourt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@kevin-dp kevin-dp changed the title feat (sync-service): clean all shapes when switching to a different DB feat (sync-service)!: clean all shapes when switching to a different DB Sep 16, 2024
@kevin-dp kevin-dp merged commit c842835 into main Sep 16, 2024
23 checks passed
@kevin-dp kevin-dp deleted the kevin/detect-db-change branch September 16, 2024 11:50
KyleAMathews pushed a commit that referenced this pull request Nov 1, 2024
…DB (#1703)

Fixes #1689.
This PR uses Postgres' `system_identifier` to detect when Electric is
connected to a different Postgres database than before. When that is the
case, we log a warning and clean all shapes. Cleaning all shapes is
consistent with how we handle Point In Time Recoveries (where we also
clean all shapes).

Note: this is a breaking change because we modify the structure of the
timeline we store persistently. We used to just store the timeline ID,
but now we store a list `[pg_id, timeline_id]` so we can't read out old
persisted timeline information as we are expecting the new structure.
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.

Electric doesn't clean shapes after connecting to a new postgres with a different schema
2 participants