How to fix dropdb error during restore-postgres ?

Sometimes restore-postgres.sh in Private Cloud installations (OPDK) fail with the following error :

dropdb: database removal failed: ERROR: database "apigee" is being accessed by other users

Why does this happen and how can it be resolved ?

1 2 412
2 REPLIES 2

This error occurs because there are active connections to the backend. It can be resolved by terminating the connections using the following command :

select pg_terminate_backend(procpid) from pg_stat_activity where datname = 'apigee'

The procID or process ID of an active backend can be found from the pid column of the pg_stat_activity view, or by listing the postgres processes on the server (using ps on Unix or the Task Manager on Windows). The role of an active backend can be found from the usename column of the pg_stat_activity view."

Does this mean that the packaged scripts might need to be modified?