I am trying to refresh one of our staging databases with the production data. I created a database called pulse_temp and imported the data from production. After this I executed the below command to terminate all the active connections on the pulse database which I want to drop.
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname= 'pulse';
pg_terminate_backend
----------------------
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
t
(90 rows)
Then I executed the below command to rename the current database to a random name.
ALTER DATABASE pulse RENAME TO pulse_temp1;
ERROR: database "pulse" is being accessed by other users
DETAIL: There are 90 other sessions using the database.
I am getting the above error even after terminating the sessions.
I even restarted the DB instance but this error seems to persist.
Any thoughts an why it is happening and ways to resolve the issue?