Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I have a logical replication between 2 databases in the same postgres server?

I am creating a logical replication between to databases of two different applications. However at development environment my databases stays at the same postgres docker container.

My application uses rails, and so I created a migration to create the subscription from the publisher. But when I run it, it just holds forever. If I create another container and separates the databases the subscription goes swell.

Is there anyway I can do it to run at the same container?

like image 844
Rafael Costa Avatar asked May 16 '26 13:05

Rafael Costa


1 Answers

Looks like you have run into this caveat spelled out in the docs, and need to follow the two-step procedure described there:

Creating a subscription that connects to the same database cluster (for example, to replicate between databases in the same cluster or to replicate within the same database) will only succeed if the replication slot is not created as part of the same command. Otherwise, the CREATE SUBSCRIPTION call will hang. To make this work, create the replication slot separately (using the function pg_create_logical_replication_slot with the plugin name pgoutput) and create the subscription using the parameter create_slot = false.

like image 79
jjanes Avatar answered May 19 '26 03:05

jjanes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!