# PostgreSQL: "conflict with recovery" error message

**URL:** <https://community.cdata.com/t/postgresql-conflict-with-recovery-error-message/823>\
**Category:** CData Virtuality \[Archived\]\
**Tags:** article, cdata-virtuality\
**Created:** [July 12, 2024, 4:10pm UTC](https://community.cdata.com/t/postgresql-conflict-with-recovery-error-message/823 "2024-07-12T16:10:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@anonymous](https://community.cdata.com/u/anonymous)\
**Post date:** [July 12, 2024, 4:10pm UTC](https://community.cdata.com/t/postgresql-conflict-with-recovery-error-message/823/1 "2024-07-12T16:10:28Z")

</div>

This article should help address error messages such as “PSQLException-ERROR: canceling statement due to conflict with recovery” or "FATAL: terminating connection due to conflict with recovery Detail: User query might have needed to see row versions that must be removed. Hint: In a moment you should be able to reconnect to the database and repeat your command.&nbsp;"

This error does not originate in Data Virtuality, rather it has to do with the PostgreSQL replication configuration. Usually, that means that you are accessing a slave replica which is configured as a Hot Standby replica.

In such configuration, the default behavior of PostgreSQL is that any new changes coming from the master server are killing all other queries which use the same data after waiting a very short amount of time, which is 30 seconds per default.

Here is some further information on the subject:

> **[26.4. Hot Standby](https://www.postgresql.org/docs/9.0/hot-standby.html)**
>
> 26.4. Hot Standby # 26.4.1. User's Overview 26.4.2. Handling Query Conflicts 26.4.3. Administrator's Overview 26.4.4. Hot Standby Parameter Reference 26.4.5. Caveats …

The way to solve this is for older PostgreSQL versions to increase both PostgreSQL parameters discussed here:

> **[19.5. Write Ahead Log](https://www.postgresql.org/docs/9.0/runtime-config-wal.html)**
>
> 19.5. Write Ahead Log # 19.5.1. Settings 19.5.2. Checkpoints 19.5.3. Archiving 19.5.4. Recovery 19.5.5. Archive Recovery 19.5.6. Recovery Target 19.5.7. WAL …

A more elegant way to solve this in the newer versions of PostgreSQL is by enabling the parameter hot\_standby\_feedback, as described here

> **[19.6. Replication](https://www.postgresql.org/docs/9.4/runtime-config-replication.html)**
>
> 19.6. Replication # 19.6.1. Sending Servers 19.6.2. Primary Server 19.6.3. Standby Servers 19.6.4. Subscribers These settings control the behavior of the …

If none of the above is possible for some reason, for example, if the PostgreSQL configuration cannot be changed - in many cases it can be helpful to set retry count on the affected replication job to \>1 with a delay of several seconds. In this case, the job will retry the operation, and there is a possibility that on one of the retries no conflict with the master server will occur.
