pg_sync_replication_slots()

用于同步逻辑故障转移复制槽的函数

pg_sync_replication_slots() 是一个用于同步逻辑故障转移复制槽的系统函数。

pg_sync_replication_slots() 已于 PostgreSQL 17 中添加。

用法

pg_sync_replication_slots () → void

pg_sync_replication_slots() 只能在备用服务器上执行。

任何临时同步的槽都不能用于逻辑解码,并且在备用服务器提升为主服务器后必须删除。

使用前提条件

备用服务器必须在主服务器上拥有一个物理复制槽。

必须满足以下配置前提条件

  • hot_standby_feedback 必须设置为 on
  • wal_level 必须设置为 logical
  • primary_conninfo 必须已设置,并且包含有效的 dbname 设置

变更历史

示例

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

分类

逻辑复制, 复制槽, 系统函数

另请参阅

pg_replication_slots, sync_replication_slots, synchronized_standby_slots

反馈

对于“pg_sync_replication_slots()”的任何评论、建议或更正,请在此 提交