在 PostgreSQL 13 上更改 "wal_level"(通过客户端会话)未得到遵守

Changing "wal_level" on PostgreSQL 13 (via client session) is not being respected

在 运行 PostgreSQL 13 实例上,我尝试按如下方式修改它的 wal_level 系统设置,但没有得到遵守:

postgres@localhost:postgres> SHOW wal_level
+-------------+
| wal_level   |
|-------------|
| replica     |
+-------------+
SHOW
Time: 0.021s

postgres@localhost:postgres> ALTER SYSTEM SET wal_level = logical;
ALTER SYSTEM
Time: 0.007s

postgres@localhost:postgres> SHOW wal_level
+-------------+
| wal_level   |
|-------------|
| replica     |
+-------------+
SHOW
Time: 0.021s

postgres@localhost:postgres>

不幸的是,这是由 Postgres 人员在 DockerHub 映像中设置的,因此仅修改配置文件并重新启动并非易事。确实可以采取变通办法,但我希望社区可以建议一种通过 Postgres 客户端会话实时执行此操作的方法。

编辑(下面的评论补充)

postgres@localhost:postgres> select * from pg_settings where name ='wal_level';
--+-----------------------------------+------------+-------------+--------------+--------------+-------------------+
  | enumvals                          | boot_val   | reset_val   | sourcefile   | sourceline   | pending_restart   |
--+-----------------------------------+------------+-------------+--------------+--------------+-------------------|
  | ['minimal', 'replica', 'logical'] | replica    | replica     | <null>       | <null>       | False             |
--+-----------------------------------+------------+-------------+--------------+--------------+-------------------+

检查 select * from pg_settings where name ='wal_level'; 上的上下文字段 使用此值,您可以看到您需要什么“重启”级别

更多信息https://www.postgresql.org/docs/current/view-pg-settings.html

但是,在文档中,对于 wal_level 说:

wal_level (enum)

wal_level determines how much information is written to the WAL. The default value is replica, which writes enough data to support WAL archiving and replication, including running read-only queries on a standby server. minimal removes all logging except the information required to recover from a crash or immediate shutdown. Finally, logical adds information necessary to support logical decoding. Each level includes the information logged at all lower levels. This parameter can only be set at server start.

https://www.postgresql.org/docs/current/runtime-config-wal.html

正如您将在文档中看到的,wal_level 不能在不重新启动 PostgreSQL 服务器的情况下更改。别无选择。