DBAtlas · Database operations atlas

55006: object_in_use

PostgreSQL

What does it mean?

The operation cannot be performed on the target object (usually a database) because it is being used by other sessions. For example, a database with active connections cannot be dropped.

Why does it happen?

Open connections to the database during DROP DATABASE; an operation requiring an exclusive lock on an object in use; another session holding the object.

How to fix it

Find and terminate open connections to the target database: SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'db_name' AND pid <> pg_backend_pid(); Block new connections (if needed). On PostgreSQL 13+, drop it while forcibly closing connections: DROP DATABASE db_name WITH (FORCE);

Open in DBAtlas →

More from this engine