Due to a bug in PostgreSQL exporter, an extra stale database connection does not allow deletion of a PostgreSQL database and shows the following error.
DROP DATABASE "database name";
ERROR: database "database name" is being accessed by other users
DETAIL: There is 1 other session using the database.
Force drop: Use
DROP DATABASE <database-name> WITH (FORCE); instead of
DROP DATABASE <database-name>; It may fail if the database user does not have permissions to terminate existing database connections.
Exclude database from metrics collection: You can temporarily or permanently exclude a database from metrics collection which will not allow the postgresql exporter to connect to the database.
Create new application configuration template called
Exclude database metrics.
Add deployment time variable called
<database-name>when creating or editing a PostgreSQL data service deployment.
DROP DATABASE <database-name>, to remove the database.