---
# System prepended metadata

title: Postgres canceling statement due to conflict with recovery problem

---

# Postgres canceling statement due to conflict with recovery problem

Un-optimized GetTopicsV2 endpoint causing locks on read replica. Amount to "parallel queries" overloaded DB, so many of them took long time.

Changes of data on master cancelled queries on replica. Made disaster
https://gitlab.ack.ee/Infra/flash-sport/flash-sport-ghz-performance-tests/-/jobs/954384

There are parameters for this: https://stackoverflow.com/a/47661313

I thought I will be really generous if I increase "time before cancel" to 5 seconds: https://gitlab.ack.ee/Infra/flash-sport/flash-sport-infrastruktura-development/-/commit/7602a0e51b651679dfe7fd54c0959d11b26f9255

Turned out to be 5ms. Plus... default is 30 seconds: https://www.postgresql.org/docs/9.6/runtime-config-replication.html

Increase to 50 seconds: https://gitlab.ack.ee/Infra/flash-sport/flash-sport-infrastruktura-development/-/commit/da12c96f775dbb498012e0aad48c0559ad22afd1

But it made replication lag![](https://i.imgur.com/z1izUkO.png)

Only solution is fast SQL queries and... cache.