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

How does pgroll interact with PG replication? #578

Open
chris-braidwell opened this issue Jan 8, 2025 · 1 comment
Open

How does pgroll interact with PG replication? #578

chris-braidwell opened this issue Jan 8, 2025 · 1 comment

Comments

@chris-braidwell
Copy link

chris-braidwell commented Jan 8, 2025

Thank you for a brilliant piece of work.

Is pgroll aware of replication? For example, if DB1 has a PG publication and DB2 is a client for that publication. If I change a column in such a way that pgroll creates a new column that coexists with the original column for a time, then later the original column is dropped and the new column is renamed -- how would I coordinate that change with the replication client?

Similar question when renaming a table, adding a new column to a replicated table, many other scenarios.

Thanks

@tsg
Copy link
Member

tsg commented Jan 10, 2025

hi @chris-braidwell . I assume you are referring to logical replication, right?

Currently pgroll doesn't do anything special for logical replication, so doing the schema changes on the replica in sync with the primary is up to you.

I am thinking that the following process should work, though:

  • do pgroll start on the replica first. Because pgroll start does the "expand" phase, this should keep replication flowing normally.
  • do pgroll start on the primary. Now the two both have the "expanded" set of columns.
  • do the application roll-out
  • do pgroll complete on the primary first. This will "contract" the set of columns.
  • do pgroll complete on the secondary.

It's not ideal because you need to manually orchestrate these steps, but actually we can use the expand/contract pattern of pgroll to our advantage here. Without it, you'd be forced to only do additive changes in the context of logical replication.

Logical replication/CDC is in general an area of interest for us already, because of https://github.com/xataio/pgstream to which we want to add Postgres->Postgres replication support. When we do that, an integration between pgroll and pgstream would be interesting, perhaps we find a more automatic solution to the above.

Let me know what you think, or if I misunderstood anything.

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

No branches or pull requests

2 participants