我们目前正在使用PostgreSQL 13.4、Patroni、领事和Confd构建一个PostgreSQL集群。安装是成功的(Patroni集群正在使用一个主服务器和一个副本进行复制),我们正在尝试使用具有不同复制设置(特别是synchronous_commit )的pgbench进行一些基准测试。
文档明确指出,主表上的synchronous_commit的有效值是:
随着有关网络故障和崩溃的安全性的提高(广义地说)。因此,我们的想法是为每个设置生成一些基准测试(使用pgbench)。正如文档所解释的那样,synchronous_commit的唯一有效值是on和off (当synchronous_standby_names为空)。我们有synchronous_standby_names作为*。
然而,当更改synchronous_commit的值时,它似乎没有改变任何东西。示例:
gobsux59:/etc/patroni # su - postgres
postgres@gobsux59:~> psql
psql (13.4)
Type "help" for help.
postgres=# show synchronous_commit;
synchronous_commit
--------------------
off
(1 row)
postgres=# alter system set synchronous_commit = 'local';
ALTER SYSTEM
postgres=# show synchronous_commit;
synchronous_commit
--------------------
off
(1 row)
postgres=# alter system set synchronous_commit = 'remote_write';
ALTER SYSTEM
postgres=# show synchronous_commit;
synchronous_commit
--------------------
off
(1 row)
postgres=# alter system set synchronous_commit = 'on';
ALTER SYSTEM
postgres=# show synchronous_commit;
synchronous_commit
--------------------
off
(1 row)
postgres=# alter system set synchronous_commit = 'remote_apply';
ALTER SYSTEM
postgres=# show synchronous_commit;
synchronous_commit
--------------------
off
(1 row)
postgres=#这里总是有一些系统干扰的可能性,所以我检查了synchronous_commit是否列在其他适用的配置文件中:
postgres@gobsux59:~/data> grep synchronous_commit *
postgresql.auto.conf:synchronous_commit = 'remote_apply'
postgresql.base.conf:#synchronous_commit = on # synchronization level;
postgresql.base.conf.backup:#synchronous_commit = on # synchronization level;您可以看到,postgresql.auto.conf (由PostgreSQL基于ALTER SYSTEM语句自动编写的配置文件)包含最后使用ALTER SYSTEM设置的值,但是当查询数据库时会显示不同的值。
我已经研究了不同的配置作用域,在这些配置作用域中,我覆盖了另一个范围,而不是我正在查询的范围,但情况似乎并非如此(虽然我认识到,可以为每个连接、每个事务、每个集群设置许多设置)。
我不知道如何进一步理解这个问题,我希望得到任何帮助。
发布于 2021-10-25 09:13:46
ALTER SYSTEM所做的就是编辑数据目录中的postgresql.auto.conf。
要使更改生效,您必须重新加载服务器:
SELECT pg_reload_conf();这可以在服务器运行时完成,不会中断操作。它告诉PostgreSQL从文件中加载新的配置参数。
https://dba.stackexchange.com/questions/301613
复制相似问题