Hi team,
I’m hitting two related issues trying to delete an individual database from a Managed Postgres (MPGv2) cluster, and wanted to report them together since they compound.
Problem 1 — Dashboard “Delete database” returns 400
In the dashboard (cluster → Databases → per-row Delete), confirming the delete shows:
Failed to delete database (status 400)
This is 100% reproducible on a freshly-created database, and intermittent on older ones — clicking Delete many times in a row will eventually succeed.
What I found while debugging:
- The backend appears to issue a plain
DROP DATABASE(noWITH (FORCE)), so it fails whenever any session is connected to the target DB. - The only connection is Fly’s own monitoring role —
_pgmonitor/application_name = pg_exporter. On a fresh database it stays connected ~22s, disconnects for ~9s, then reconnects (new PID), on roughly a 30s
cycle. - So a delete only succeeds if the click happens to land in the ~9s window with no
pg_exporterconnection. In practice you have to spam the Delete button for ~30s.
Suggested fix: have the delete use DROP DATABASE ... WITH (FORCE), or terminate active sessions (including the monitoring connection) before dropping — so a single click works deterministically.
Problem 2 — No programmatic way to delete a database
There seems to be no supported non-dashboard path to drop a database:
flyctl mpg databasesonly hascreate/list— nodelete.DELETE /api/v1/postgresv2/{cluster}/databases/{name}returns 404 (route doesn’t exist), and there’s no GraphQL mutation for it.- Connecting and running
DROP DATABASEdoesn’t work either: all MPG databases are owned by thepostgressuperuser, and the defaultfly-user(Schema Admin) getsERROR: must be owner of database, while
postgrescredentials aren’t retrievable.
Could you add a flyctl mpg databases delete and/or a REST endpoint? Orphaned databases (e.g. from a rolled-back automation that deleted the role but not the DB) currently have no clean self-service cleanup path
other than the dashboard button above.
Thanks!