数据复制服务 DRS-全量或增量阶段失败报错,关键词“Initialize logical replication stream failed, the source database may have a long transaction”:解决方案

时间:2024-09-26 16:04:05

解决方案

  1. 检查源库复制槽数量是否达到最大复制槽数的限制。如果是,建议删除源库不再使用的复制槽,或者增大max_replication_slots后重启源库。

    • 查询逻辑复制槽数量:
      select count(1) from pg_replication_slots;
    • 查询最大复制槽数量:
      select setting as number from pg_settings where name = 'max_replication_slots';

  2. 确定源库是否存在长事务未提交,如果有,则会建槽超时,导致任务失败。

    • 查询事务情况:
      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);

support.huaweicloud.com/trouble-drs/drs_13_0127.html