根据报错信息,在主库上执行长时间查询过程中,由于此查询涉及的记录有可能在主库上被更新或删除,根据 PostgreSQL的mvcc机制,更新或删除的数据不是立即从物理块上删除,而是之后autovacuum...,然而,这种方法也会带来一定的弊端,主库上的表可能出现膨胀,主库表的膨胀程度与表上的写事务和从库执行时间有关,此参数默认为off
案例:
CentOS7.5+PG版本11.5
pgMaster 为主库...= off
然后reload下PG的配置使其生效
在主库pgMaster 上创建测试表:
\c postgres
create table test_per2 ( id int , flag int...);
insert into test_per2 (id) select * from generate_series(1,1000000) ;
编写pgbench压测脚本 update_per2.sql...-Upostgres -n N -M prepared -f update_per2.sql
然后,到pgSlave备库去执行下查询操作:
postgres=# select pg_sleep(12)