postgres-operator icon indicating copy to clipboard operation
postgres-operator copied to clipboard

successful switchover, a way to terminate connections on an old master

Open pere3 opened this issue 3 years ago • 0 comments

Overview

Hello crunchy team! Thanks for a superb product on a postgres-operator landscape.

We currently are in a process of adapting this solution on our GKE-based infrastructure with a scale of 260-300 databases in a single cluster, and so far it's looking good and promising, thanks for a detailed documentation.

I wonder what yours take on a problem that we are currently facing:

  • we are deploying postgres as two replicas cluster
  • our application uses -ha svc to connect to the main replica
  • we perform controllable switchover (we update the cluster spec and apply an annotation)
  • switchover is performed well and a replica switched
  • but our application (python + asyncpg) still manages old connections to now-read-only replica, which causing exceptions ReadOnlySQLTransactionError until amount of them reaches the limit to terminate connection by asyncpg driver

so switchover executes in a matter of seconds, but our application still uses old connections for much longer (maybe until restart, if limit of failed ops could not be reached) - what is proposed way to solve this behavior?

Environment

  • Platform: GKE
  • Platform Version: 5.1.2
  • PGO Image Tag: ubi8-5.1.2-0
  • Postgres Version 14
  • Storage: PVC

pere3 avatar Jul 28 '22 11:07 pere3