postgresql之同步流复制陷阱

根据同步流复制模式,需要等待至少一个备库接受wal并返回确认信息后主库才向客户端返回成功,一方面保障数据完整性,另一方面如果备库宕机,主库的写操作将出现等待状态,实验环境为一主一备

模拟备库故障

[postgres@localhost pg_root]$ pg_ctl stop -m fast
waiting for server to shut down....2021-11-01 05:15:10.927 EDT [3890] LOG:  received fast shutdown request
2021-11-01 05:15:10.928 EDT [3890] LOG:  aborting any active transactions
2021-11-01 05:15:10.928 EDT [3895] FATAL:  terminating walreceiver process due to administrator command
2021-11-01 05:15:10.929 EDT [3892] LOG:  shutting down
2021-11-01 05:15:10.932 EDT [3890] LOG:  database system is shut down
 done
server stopped

在主库上查询,查询不受影响

postgres=# select * from ceshizhujixieru;
 id
----
  2
(1 row)

在主库上插入数据,一直除以等待状态

postgresql之同步流复制陷阱

 

 通常一主一备不会采用同步复制,因为备库宕机后会对生产产生影响,postgresql支持一主多备,

postgresql之同步流复制陷阱

 

上一篇:PostgreSQL子查询别名改造(兼容Oracle)


下一篇:将PostgreSQL插件移植到openGauss指导