postgresql因在从库备份时间长而失败

文章目录

环境

系统平台:Linux x86-64 Red Hat Enterprise Linux 7,Linux x86-64 Red Hat Enterprise Linux 8

版本:10.4,11,12,13,14

症状

在standby从库用pg_dump因数据库比较大备份时间久,抛出错误备份失败。报错信息如下

复制代码
postgres@vm112 ~]$ pg_dump -dpostgres -f a.dmp
pg_dump: error: Dumping the contents of table "t1" failed: PQgetResult() failed.
pg_dump: error: Error message from server: ERROR:  canceling statement due to conflict with recovery
DETAIL:  User query might have needed to see row versions that must be removed.

问题原因

standby从库有个wal replay进程在进行wal回放, 如果回放过程中有查询会话和回放的内容发生了冲突, 那么wal回放会进行等待,等待的时间不会大于参数max_standby_streaming_delay的设定。当等待超过这个时间时, wal replay会cancel与之有冲突的所有查询会话, 然后开始恢复。

解决方案

1、查询max_standby_streaming_delay设置

sql 复制代码
postgres=# show max_standby_streaming_delay ;
 max_standby_streaming_delay 
-----------------------------
 3min
(1 row)

2、调大max_standby_streaming_delay的设置

sql 复制代码
postgres=#  alter system set max_standby_streaming_delay='10min';
ALTER SYSTEM
postgres=# select pg_reload_conf();
 pg_reload_conf 
----------------
 t
(1 row)
postgres=# show max_standby_streaming_delay ;
 max_standby_streaming_delay 
-----------------------------
 10min
(1 row)

3、重新进行备份,备份成功

sql 复制代码
[postgres@vm112 ~]$  pg_dump -dpostgres -f a.dmp;
[postgres@vm112 ~]$  

报错编码

pg_dump: error: Error message from server: ERROR: canceling statement due to conflict with recovery

相关推荐
倔强的石头_20 小时前
《Kingbase护城河》——数据库存储空间全景探测与精细化瘦身实战
数据库
冬奇Lab1 天前
每日一个开源项目(第134篇):Zvec - 阿里开源的嵌入式向量数据库,向量搜索界的 SQLite
数据库·人工智能·llm
ClouGence2 天前
Oracle CDC 架构优化:从主库直连到 DataGuard 备库同步
数据库·后端·oracle
无响应de神2 天前
三、用户与权限管理
数据库·mysql
大树883 天前
金刚石散热越强,管路越先见顶
大数据·运维·服务器·人工智能·ai
摇滚侠3 天前
Linux CentOS7 rpm 安装 MySQL 5.7
linux·运维·mysql
霸道流氓气质3 天前
领域驱动设计(DDD)在 Spring Boot 微服务中的实践指南
运维·spring boot·微服务
Inhand陈工3 天前
基于台达PLC与映翰通IG502的智慧水产养殖精准投喂与远程运维解决方案
运维·人工智能·物联网·阿里云·信息与通信
酣大智3 天前
ARP代理--工作原理
运维·网络·arp·arp代理
麦聪聊数据3 天前
数据服务化时代:企业数据能力输出的核心路径
数据库