Using Replication Slots
Replication Slots are a new feature in PostgreSQL 9.4. They allow you to define your replication architecture explicitly. They also allow you to track details of nodes even when they are disconnected. Replication Slots work with both PSR and LSR.
Replication Slots make data persist about the downstream node. They are crash-safe, so if a connection is lost, the slot still continues to exist. By tracking data on downstream nodes, we avoid these problems:
When a standby disconnects, the feedback data provided by
hot_standby_feedback
is lost. When the standby reconnects, it may be sent cleanup records that result in query conflicts. Replication Slots remember the standby'sxmin
value even when disconnected, ensuring that cleanup conflicts can be avoided.When a standby disconnects, the knowledge of which WAL files were required is lost. When the standby reconnects, we may have discarded the required WAL files, requiring us to completely regenerate the downstream node (assuming...