跳转到主要内容

superuser_reserved_connections

superuser_reserved_connections 定义为超级用户保留的连接槽数量。
说明

Fact — 官方简述译文:设置为超级用户保留的连接槽数量。

身份

类型 , integer
上游 pg_settings 类型
Context , postmaster
修改后需要重启数据库
单位 ,
原始单位
范围 , 0262143
最后在档版本的原始上下限
枚举值 ,
非枚举类型记为 —
分类 , Connections and Authentication / Connection Settings
上游分类
最后 boot 值 , 3
3

生命周期

Fact
首次观测 PG9.0(研究下界)
在档版本 PG9.0–19 Beta 3
移除版本
引入提交 不作断言:早于 PG9.0 研究边界
提交日期
Discussion

默认值变迁

PG9.0–19 Beta 3 实测 boot 默认值
版本 原始 boot_val 单位 人类可读值
PG9.0–19 Beta 3 3 3

机制详解

superuser_reserved_connections:设置为超级用户保留的连接槽数量。普通槽位与 reserved_connections 容量耗尽后,只有超级用户能使用这些槽位,从而保留应急入口。

superuser_reserved_connections 属于 POSTMASTER 上下文:PostgreSQL 在服务器启动时读取它,重新加载配置或会话 SET 都不能使新值生效。

reserved_connections 与 superuser_reserved_connections 从 max_connections 中划出特权层;连接池、监控、复制、维护与故障转移必须共同纳入同一后端总预算。

调优建议

提示

Advice。 以下建议是工作负载起点,必须用真实测量验证。

场景 建议
OLTP 在 max_connections 总量内,按独立应急主体数量、连接池行为与故障转移操作确定 superuser_reserved_connections;测试普通连接饱和后管理入口仍可用。
OLAP 为重型分析会话之外的控制、监控与取消预留足够槽位,但不要让预留吞噬本就较小后端池的过高比例。
小规格 让 superuser_reserved_connections 相对 max_connections 保持适度,同时至少保留一条经过测试的应急路径;饱和时预留槽不会供普通客户端使用。

Pigsty 取值

以下值来自固定 8 核、32 GiB、100 GiB SSD 夹具,并按 PG19 Beta 3 渲染当前 Pigsty 模板;这不表示 Pigsty 当前支持该历史或测试版本。

模板 有效值 与上游 boot 比较 源表达式
OLTP 10 不同于 boot 值 10
OLAP 10 不同于 boot 值 10
CRIT 10 不同于 boot 值 10
TINY 10 不同于 boot 值 10
注意

Advice — 待人工复核。 当前 Pigsty 模板投影事实:OLTP: PG9.0–19 Beta 3 = 10 (dcs);OLAP: PG9.0–19 Beta 3 = 10 (dcs);CRIT: PG9.0–19 Beta 3 = 10 (dcs);TINY: PG9.0–19 Beta 3 = 10 (dcs)。 建议(待人工复核)——编辑推断:十个应急槽在连接池前置服务中提供高于上游的监控、修复与故障转移操作余量。

常见坑

  • 期待重新加载或 SET 激活 superuser_reserved_connections,而它实际需要受控重启服务器。
  • 把预留槽计算在 max_connections 之外,而所有层级实际共享同一总上限。
  • 应急响应预留过少,或预留过多以致饱和时普通应用容量骤降。
  • 没有回滚计划及客户端或运维兼容测试,就全局修改 superuser_reserved_connections。

listen_addresses · port · max_connections · reserved_connections · unix_socket_directories

参考资料