Thread: [HACKERS] Better error message for trying to drop a DB with open subscriptions?
[HACKERS] Better error message for trying to drop a DB with open subscriptions?
From
Josh Berkus
Date:
All: The problem: postgres=# drop database bookdata; ERROR: database "bookdata" is being accessed by other users DETAIL: There is 1 other session using the database. postgres=# \c bookdata You are now connected to database "bookdata" as user "postgres". bookdata=# drop subscription wholedb; NOTICE: dropped replication slot "wholedb" on publisher DROP SUBSCRIPTION bookdata=# \c postgres You are now connected to database "postgres" as user "postgres". postgres=# drop database bookdata; DROP DATABASE Is there any easy way for us to detect that the "user" accessing the target database is actually a logical replication subscription, and give the DBA a better error message (e.g. "database 'bookdata' still has open subscrptions")? -- Josh Berkus Containers & Databases Oh My!
Re: [HACKERS] Better error message for trying to drop a DB with open subscriptions?
From
Craig Ringer
Date:
On 21 July 2017 at 07:09, Josh Berkus <josh@berkus.org> wrote:
All:
The problem:
postgres=# drop database bookdata;
ERROR: database "bookdata" is being accessed by other users
DETAIL: There is 1 other session using the database.
postgres=# \c bookdata
You are now connected to database "bookdata" as user "postgres".
bookdata=# drop subscription wholedb;
NOTICE: dropped replication slot "wholedb" on publisher
DROP SUBSCRIPTION
bookdata=# \c postgres
You are now connected to database "postgres" as user "postgres".
postgres=# drop database bookdata;
DROP DATABASE
Is there any easy way for us to detect that the "user" accessing the
target database is actually a logical replication subscription, and give
the DBA a better error message (e.g. "database 'bookdata' still has open
subscrptions")?
Good idea. Also, this affects any active logical (db-specific) replication slot, not just built-in logical replication.
--
Re: [HACKERS] Better error message for trying to drop a DB with open subscriptions?
From
Jeff Janes
Date:
On Thu, Jul 20, 2017 at 4:09 PM, Josh Berkus <josh@berkus.org> wrote:
All:
The problem:
postgres=# drop database bookdata;
ERROR: database "bookdata" is being accessed by other users
DETAIL: There is 1 other session using the database.
postgres=# \c bookdata
You are now connected to database "bookdata" as user "postgres".
bookdata=# drop subscription wholedb;
NOTICE: dropped replication slot "wholedb" on publisher
DROP SUBSCRIPTION
bookdata=# \c postgres
You are now connected to database "postgres" as user "postgres".
postgres=# drop database bookdata;
DROP DATABASE
Is there any easy way for us to detect that the "user" accessing the
target database is actually a logical replication subscription, and give
the DBA a better error message (e.g. "database 'bookdata' still has open
subscrptions")?
+1
Better yet would be to just cascade the drop, but I assume that would be harder to do.
Cheers,
Jeff