pg_sync_replication_slots() 是一个用于同步逻辑故障转移复制槽的系统函数。
pg_sync_replication_slots() 已于 PostgreSQL 17 中添加。
用法
pg_sync_replication_slots () → void
pg_sync_replication_slots() 只能在备用服务器上执行。
任何临时同步的槽都不能用于逻辑解码,并且在备用服务器提升为主服务器后必须删除。
使用前提条件
备用服务器必须在主服务器上拥有一个物理复制槽。
必须满足以下配置前提条件
hot_standby_feedback必须设置为onwal_level必须设置为logicalprimary_conninfo必须已设置,并且包含有效的dbname设置
变更历史
- PostgreSQL 17
- 添加(提交 ddd5f4f5)
示例
pg_sync_replication_slots() 的基本用法示例
postgres=# SELECT pg_sync_replication_slots(); pg_sync_replication_slots --------------------------- (1 row)
尝试在没有必需的物理复制槽的情况下执行 pg_sync_replication_slots()
postgres=# SELECT pg_sync_replication_slots(); ERROR: bad configuration for slot synchronization HINT: "primary_slot_name" must be defined.
尝试在主服务器上执行 pg_sync_replication_slots()
postgres=# SELECT pg_sync_replication_slots(); ERROR: replication slots can only be synchronized to a standby server
