# output_plugin_libraries

> output_plugin_libraries：列出可作为逻辑解码输出插件指定的库。它是 PG14–18 的 superuser 参数；最新实测启动默认值为 pgoutput, test_decoding。
---

> [!NOTE]
> **Fact — 官方简述译文**：列出可作为逻辑解码输出插件指定的库。

## 身份 {#identity}

| 字段 | 值 | 含义 |
| --- | --- | --- |
| 类型 | `string` | 上游 pg_settings 类型 |
| Context | `superuser` | 超级用户可在运行时修改 |
| 单位 | — | 原始单位 |
| 范围 | — | 最后在档版本的原始上下限 |
| 枚举值 | — | 非枚举类型记为 — |
| 分类 | Replication / Sending Servers | 上游分类 |
| 最后 boot 值 | `pgoutput, test_decoding` | pgoutput, test_decoding |
{.fields meta="-"}

## 生命周期 {#lifecycle}

| Fact | 值 |
| --- | --- |
| 首次观测 | PG14 |
| 在档版本 | PG14–19 Beta 3 |
| 移除版本 | 否 |
| 引入提交 | [`bf3842a64f5d`](https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=bf3842a64f5df489fab31b82aaeb9067ac938fde) — Add an output_plugin_libraries GUC to bless trusted output plugins |
| 提交日期 | 2026-08-10 |
| Discussion | — |

## 默认值变迁 {#default-history}

| 版本 | 原始 `boot_val` | 单位 | 人类可读值 |
| --- | --- | --- | --- |
| PG14–19 Beta 3 | `pgoutput, test_decoding` | — | pgoutput, test_decoding |
{.full-width caption="PG9.0–19 Beta 3 实测 boot 默认值"}

## 机制详解 {#mechanism}

列出可作为逻辑解码输出插件指定的库。超级用户或获授 SET 权限的角色可在相应的会话或配置作用域中修改它。

逻辑解码只接受该服务端白名单中的输出插件库名，按 LOAD 规则解释并要求插件名精确匹配。加入库是信任决策，因为插件代码在服务器进程内部执行。

应把 output_plugin_libraries 与 wal_level、max_wal_senders、max_replication_slots 一起监控和变更。先在对应角色与真实负载上验证，再按其 superuser context 选择会话修改、reload 或 restart；历史默认值并不等于当前有效值。

## 调优建议 {#tuning-advice}

> [!TIP]
> **Advice。** 以下建议是工作负载起点，必须用真实测量验证。

| 场景 | 建议 |
| --- | --- |
| OLTP | 只列出已安装、已审计且确有消费者使用的输出插件；修改后用最低权限逻辑复制用户验证，并把插件升级纳入服务器发布。 |
| OLAP | ETL 解码插件同样是进程内代码，不要为方便使用通配或宽泛路径；验证大事务的内存、WAL 保留与插件输出。 |
| 小规格 | 不做逻辑解码就保留内置小白名单；增加 wal2json 等插件前确认包来源、版本兼容与维护责任。 |
{.full-width}

## Pigsty 取值 {#pigsty}

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

| 模板 | 有效值 | 与上游 boot 比较 | 源表达式 |
| --- | --- | --- | --- |
| OLTP | `pgoutput, test_decoding, wal2json` | 不同于 boot 值 | `'pgoutput, test_decoding, wal2json'` |
| OLAP | `pgoutput, test_decoding, wal2json` | 不同于 boot 值 | `'pgoutput, test_decoding, wal2json'` |
| CRIT | `pgoutput, test_decoding, wal2json` | 不同于 boot 值 | `'pgoutput, test_decoding, wal2json'` |
| TINY | `pgoutput, test_decoding, wal2json` | 不同于 boot 值 | `'pgoutput, test_decoding, wal2json'` |
{.full-width}

> [!CAUTION]
> **Advice — 待人工复核。** 当前 Pigsty 模板投影事实：OLTP: PG14–19 Beta 3 = pgoutput, test_decoding, wal2json (dcs)；OLAP: PG14–19 Beta 3 = pgoutput, test_decoding, wal2json (dcs)；CRIT: PG14–19 Beta 3 = pgoutput, test_decoding, wal2json (dcs)；TINY: PG14–19 Beta 3 = pgoutput, test_decoding, wal2json (dcs)。 建议（待人工复核）——编辑推断（待维护者人工复核）：该选择看起来意在在保持明确小型白名单的同时提供 wal2json；发布前应结合当前 Pigsty 模板、硬件夹具和运维保证复核。

## 常见坑 {#common-pitfalls}

- 在错误的主库、备库、发送端或订阅端角色上修改。
- 只看字节/时间配置，不监控真实复制延迟、槽位置与 worker 状态。
- 故障切换后新主库缺少与旧主库一致的容量或依赖。
- 用无限等待或无限 WAL 保留掩盖失效消费者。

## 关联参数 {#related-parameters}

[`wal_level`](/zh/parameters/wal-level/) · [`max_wal_senders`](/zh/parameters/max-wal-senders/) · [`max_replication_slots`](/zh/parameters/max-replication-slots/) · [`archive_mode`](/zh/parameters/archive-mode/) · [`wal_log_hints`](/zh/parameters/wal-log-hints/) · [`shared_preload_libraries`](/zh/parameters/shared-preload-libraries/)

## 参考资料 {#references}

- [PostgreSQL 19 Beta 3 — output_plugin_libraries](https://www.postgresql.org/docs/19/runtime-config-replication.html#GUC-OUTPUT-PLUGIN-LIBRARIES)
- [PostgreSQL 19 发行说明](https://www.postgresql.org/docs/19/release-19.html)
- [机器可读 GUC 全量导出](/data/guc.jsonl)
