0

TL;DR: I imagine that there is a way to temporarily disable access to a pod / service so maintenance can be done. In this case: Block access to a database so a dump can be restored.

$ kubectl exec podwith-postgresql-59b77ffb7d-fc4xj dropdb dbname
dropdb: database removal failed: ERROR:  database "dbname" is being accessed by other users
DETAIL:  There are 10 other sessions using the database.

Just rescaling ReplicaSets to 0 or killing Pods didn't turn out successfull as Kubernetes (or Helm?) does a good job in bringing stuff back up.

Background: Specifically I was updating a Helm chart that depends on the Postgresql chart as a default database. I did my due dilligence and did an sql dump of the database before attempting the upgrade. And yadayadayada, stuff hit the fan and I would like to restore the dump, but since there was a new empty Database created and the application is already running I can't delete or replace the existing database as there are active connections to it.

Mofef
  • 21
  • 3
  • Hi did you try to stop DB like described in this [section](https://www.postgresql.org/docs/current/upgrading.html#UPGRADING-VIA-PGDUMPALL) – Mark Sep 18 '19 at 08:47
  • Hi, thanks. I did, but somehow this was killing the whole pod and I was kicked out of the session. In the end I changed the port to sth different and restarted. that obviously worked but then again Kubernetes noticed that something is wrong and was all the time restarting the pod. Luckily I just had enough time to get done what I had to do in one cycle. In another cycle I reconfigured the port back to default... I would still hope there is a more clean, less hacky way to do that. – Mofef Sep 18 '19 at 11:38
  • Why you didn't stop the the pg service as described in docs? – Mark Sep 18 '19 at 12:13

0 Answers0