'my postgres database crashes after certain manipulation of an audited table raw

I get this error:

Internal Server Error

javax.persistence.OptimisticLockException: org.hibernate.exception.LockAcquisitionException: could not extract ResultSet ... connection was terminated due to conflict with recovery Detail: User was holding a relation lock for too long. ... javax.persistence.OptimisticLockException: org.hibernate.exception.LockAcquisitionException: could not extract ResultSet



Solution 1:[1]

You must have run something like DROP/ALTER TABLE, TRUUNCATE, LOCK, CLUSTER and similar commands that require an ACCESS EXCLUSIVE lock on the table on the streaming replication primary, or autovacuum truncated a table there. Such a lock is replicated and conflicts with any query running on that table on a standby server. Once max_standby_streaming_delay is exceeded, the query is canceled.

Here is some background information.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Laurenz Albe