pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathan@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Teach pg_upgrade to skip invalid databases.
Date: Thu, 05 Nov 2026 20:28:30 +0000
Message-ID: <E1xP44V-00000000MKC-0SOf@gemulon.postgresql.org> (raw)

Teach pg_upgrade to skip invalid databases.

If DROP DATABASE is interrupted at the wrong moment, it leaves the
pg_database row behind, but it is marked as invalid, i.e.,
datconnlimit is set to -2.  Such databases cannot be connected to,
and there is no supported recovery mechanism (besides of course
restoring a backup to a time before the DROP DATABASE command).
The only thing that a user can do is run DROP DATABASE on them
again.

Currently, pg_upgrade checks for invalid databases and refuses to
proceed if any exist.  This commit teaches pg_upgrade to instead
simply skip them.  The pg_database row and any associated files
won't be transferred; the invalid database will just cease to exist
on the newly upgraded cluster.  We should probably try to
automatically drop invalid databases during normal operation, too,
but that is left as a future exercise.

Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Discussion: https://postgr.es/m/CALj2ACV3jSPaMCSRQ8XZTN_meZezNyySpMJVhVBZy_qDJK2mmQ%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/37a7664a9204a7fafa04553e906aa0ae9f4a91c3

Modified Files
--------------
src/bin/pg_upgrade/check.c             | 43 +++++++++++++++-----------------
src/bin/pg_upgrade/info.c              |  5 ++--
src/bin/pg_upgrade/t/002_pg_upgrade.pl | 45 +++++-----------------------------
3 files changed, 29 insertions(+), 64 deletions(-)



Message-ID: <E1xP44V-00000000MKC-0SOf@gemulon.postgresql.org>
Permalink:  ../E1xP44V-00000000MKC-0SOf@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xP44V-00000000MKC-0SOf@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: nathan@postgresql.org
  Subject: Re: pgsql: Teach pg_upgrade to skip invalid databases.
  In-Reply-To: <E1xP44V-00000000MKC-0SOf@gemulon.postgresql.org>
  References: <E1xP44V-00000000MKC-0SOf@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox