idle_replication_slot_timeout
一个 GUC 参数,用于确定非活动的复制槽在检查点时是否应被无效化
idle_replication_slot_timeout
是一个 配置参数,用于确定非活动的复制槽在 检查点 时是否应被无效化。
idle_replication_slot_timeout
在 PostgreSQL 18 中被添加。
默认
idle_replication_slot_timeout
的默认值为:0(禁用)。
用法
idle_replication_slot_timeout
以分钟为间隔指定。如果未指定单位,则值被解释为秒,否则该值将被转换为秒。
0
(默认值)禁用 idle_replication_slot_timeout
。
如果启用,并且在复制槽处于非活动状态至少达到 idle_replication_slot_timeout
指定的时间间隔后发出检查点,则该槽将被无效化。否则,它将在下一个常规检查点被无效化,通常是在 checkpoint_timeout
的间隔。
按 PostgreSQL 版本详细信息
idle_replication_slot_timeout (PostgreSQL 19)
设置 | 0 |
单位 | s |
类别 | 复制/发送服务器 |
简短描述 | 设置复制槽在被无效化之前可以保持空闲的时间。 |
扩展描述 | |
上下文 | sighup |
变量类型 | 整数 |
来源 | 默认 |
最小值 | 0 |
最大值 | 2147483647 |
枚举值 | |
启动值 | 0 |
重置值 | 0 |
源文件 | |
源行 | |
需要重启 | false |
idle_replication_slot_timeout (PostgreSQL 18)
设置 | 0 |
单位 | s |
类别 | 复制/发送服务器 |
简短描述 | 设置复制槽在被无效化之前可以保持空闲的时间。 |
扩展描述 | |
上下文 | sighup |
变量类型 | 整数 |
来源 | 默认 |
最小值 | 0 |
最大值 | 2147483647 |
枚举值 | |
启动值 | 0 |
重置值 | 0 |
源文件 | |
源行 | |
需要重启 | false |
变更历史
- PostgreSQL 18
- 添加于(提交 ac0e3313)
示例
idle_replication_slot_timeout
的基本用法示例
postgres=# ALTER SYSTEM SET idle_replication_slot_timeout = '60s'; ALTER SYSTEM postgres=# SELECT pg_reload_conf(); pg_reload_conf ---------------- t (1 row) postgres=# SHOW idle_replication_slot_timeout; idle_replication_slot_timeout ------------------------------- 1min
如果在发出 检查点 后,该槽的空闲时间超过了 idle_replication_slot_timeout
中指定的间隔,则该槽将被无效化。
postgres=# SELECT slot_name, wal_status, invalidation_reason, NOW() - inactive_since AS idle_time FROM pg_replication_slots;
slot_name | wal_status | invalidation_reason | idle_time -----------+------------+---------------------+----------------- node2 | reserved | | 00:01:05.768958 (1 row) postgres=# CHECKPOINT; CHECKPOINT postgres=# SELECT slot_name, wal_status, invalidation_reason, NOW() - inactive_since AS idle_time FROM pg_replication_slots;
slot_name | wal_status | invalidation_reason | idle_time -----------+------------+---------------------+----------------- node2 | lost | idle_timeout | 00:01:10.339201 (1 row)
参考资料
- PostgreSQL 文档: idle_replication_slot_timeout