文档首页/
数据复制服务 DRS/
故障排除/
失败案例/
PostgreSQL->PostgreSQL实时同步/
全量或增量阶段失败报错,关键词“Initialize logical replication stream failed, the source database may have a long transaction”
更新时间:2022-10-10 GMT+08:00
全量或增量阶段失败报错,关键词“Initialize logical replication stream failed, the source database may have a long transaction”
场景描述
全量或增量同步期间DRS任务报错,同步日志界面提示:service LOGMANAGER failed, cause by: Initialize logical replication stream failed, the source database may have a long transaction: ***
可能原因
在源库创建逻辑复制槽失败。
解决方案
- 检查源库复制槽数量是否达到最大复制槽数的限制。如果是,建议删除源库不再使用的复制槽,或者增大max_replication_slots后重启源库。
- 查询逻辑复制槽数量:
select count(1) from pg_replication_slots;
- 查询最大复制槽数量:
select setting as number from pg_settings where name = 'max_replication_slots';
- 查询逻辑复制槽数量:
- 确定源库是否存在长事务未提交,如果有,则会建槽超时,导致任务失败。
- 查询事务情况:
select pid, datname, state, backend_xid, xact_start, (now() - xact_start) as cost from pg_stat_activity where backend_xid is not null order by xact_start;
- 如果需要停止长事务执行:
select pg_terminate_backend(pid);
- 查询事务情况: