错误:由于与恢复冲突而取消语句

pha*_*hok 2 postgresql replication

我收到以下错误:

ERROR: canceling statement due to conflict with recovery.
Detail: User query might have needed to see row versions that must be removed.;
nested exception in org.postgresql.util.PSQLException:ERROR:canceling statement due to conflict with recovery.
Detail: User query might have needed to see row versions that must be removed.
Run Code Online (Sandbox Code Playgroud)

当我们使用长查询时,此错误发生在备用数据库上。我们使用 PostgreSQL 版本 12.0。一台主服务器和两台备用服务器。

您能给我们解决方案吗?

Lau*_*lbe 5

主服务器上删除了一些旧的行版本VACUUM,但备用服务器上的查询仍可能需要这些行版本。因此,正在运行的查询和应用来自主数据库的更改的启动进程之间存在冲突。

PostgreSQL 等待并延迟 的重播max_standby_streaming_delay,然后取消查询。因此,为了避免这个问题,请max_standby_streaming_delay在备用设备上设置为-1。

您可以在我的博客中阅读更多内容。