pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix DROP DATABASE for databases with many ACLs
Date: Sun, 18 Aug 2024 22:28:44 +0000
Message-ID: <E1sfoOC-000LS5-IM@gemulon.postgresql.org> (raw)

Fix DROP DATABASE for databases with many ACLs

Commit c66a7d75e652 modified DROP DATABASE so that if interrupted, the
database is known to be in an invalid state and can only be dropped.
This is done by setting a flag using an in-place update, so that it's
not lost in case of rollback.

For databases with many ACLs, this may however fail like this:

  ERROR:  wrong tuple length

This happens because with many ACLs, the pg_database.datacl attribute
gets TOASTed. The dropdb() code reads the tuple from the syscache, which
means it's detoasted. But the in-place update expects the tuple length
to match the on-disk tuple.

Fixed by reading the tuple from the catalog directly, not from syscache.

Report and fix by Ayush Tiwari. Backpatch to 12. The DROP DATABASE fix
was backpatched to 11, but 11 is EOL at this point.

Reported-by: Ayush Tiwari
Author: Ayush Tiwari
Reviewed-by: Tomas Vondra
Backpatch-through: 12
Discussion: https://postgr.es/m/CAJTYsWWNkCt+-UnMhg=BiCD3Mh8c2JdHLofPxsW3m2dkDFw8RA@mail.gmail.com

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/33c615f764c32abf20bf8a5a71fcb44115551867

Modified Files
--------------
src/backend/commands/dbcommands.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1sfoOC-000LS5-IM@gemulon.postgresql.org>
Permalink:  ../E1sfoOC-000LS5-IM@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sfoOC-000LS5-IM@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tomas.vondra@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix DROP DATABASE for databases with many ACLs
  In-Reply-To: <E1sfoOC-000LS5-IM@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