华为云云数据库GaussDB长事务阻塞Undo空间回收_云淘科技

问题现象

pg_log中打印如下错误:

snapshot too old! the undo record has been forcibly discarded
xid xxx, the undo size xxx of the transaction exceeds the threshold xxx. trans_undo_threshold_size xxx,undo_space_limit_size xxx. 

在真实报错信息中,上文中的xxx为实际数据。

global_recycle_xid(Undo子系统的全局回收事务XID)长时间不发生变化。

pg_running_xacts与pg_stat_activity视图查询存在长事务,阻塞oldestxmin和global_recycle_xid推进。如果pg_running_xacts中查询活跃事务的xmin和gs_txid_oldestxmin相等,且通过pid查询pg_stat_activity查询线程执行语句时间过长,则表明有长事务卡主了回收。

select * from pg_running_xacts where xmin::text::bigint0 and vacuum  't' order by xmin::text:bigint asc 	limit 5;
select * from gs_txid_oldextxmin();
select * from pg_stat_activity where pid = 长事务所在线程PID;

处理方法

通过pg_terminate_session(pid, sessionid)终止长事务所在的会话(提醒:长事务无固定快速恢复手段,强制结束SQL语句为其中一种常用操作,属于高危操作,执行需谨慎,执行前需与业务及华为技术确认,避免造成业务失败或报错)。

父主题: snapshot too old

同意关联代理商云淘科技,购买华为云产品更优惠(QQ 78315851)

内容没看懂? 不太想学习?想快速解决? 有偿解决: 联系专家