Search code examples
postgresqlamazon-rdslogical-replication

Behavior of AWS RDS Postgres Logical Replication Slots After Failover


I'm working with AWS RDS Postgres v13 in a multi-AZ setup, using a logical replication slot for replicating to another RDS instance. After initiating a reboot with failover for testing, I noticed the replication continued seamlessly despite the switch in primary and standby roles. This was unexpected, as I thought I might need to recreate the replication slot on the new primary.

I'm curious about the mechanisms AWS RDS uses to maintain replication slot continuity through failovers, especially since the documentation doesn't clearly explain how replication slots are managed during such events. How does RDS ensure the replication slot remains functional on the new primary without manual intervention?

Would appreciate insights or resources on this topic.

Thanks


Solution

  • In AWS RDS Postgres Logical replication,whenever you create a slot in master instance the same slot is copied to standby instances.The slot in standby instance is continuously synchronised with the slot in master instance,I think probably pg_replication_slot_advance function is used on slot in standby instance to catch up with master slot.

    After fail-over,since the slot is already present in newly promoted master with updated values,therefore logical replication continues seamlessly.