Re: DROP DATABASE is interruptible
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: pgsql-hackers@postgresql.org, Evgeny Morozov <postgresql3@realityexists.net>, Tom Lane <tgl@sss.pgh.pa.us>
Date: 2023-06-21T19:02:04Z
Lists: pgsql-hackers
Hi, I'm hacking on this bugfix again, thanks to Evgeny's reminder on the other thread [1]. I've been adding checks for partiall-dropped databases to the following places so far: - vac_truncate_clog(), as autovacuum can't process it anymore. Otherwise a partially dropped database could easily lead to shutdown-due-to-wraparound. - get_database_list() - so autovacuum workers don't error out when connecting - template database used by CREATE DATABASE - pg_dumpall, so we don't try to connect to the database - vacuumdb, clusterdb, reindexdb, same It's somewhat annoying that there is no shared place for the relevant query for the client-side cases. I haven't yet added checks to pg_upgrade, even though that's clearly needed. I'm waffling a bit between erroring out and just ignoring the database? pg_upgrade already fails when datallowconn is set "wrongly", see check_proper_datallowconn(). Any opinions? I'm not sure what should be done for psql. It's probably not a good idea to change tab completion, that'd just make it appear the database is gone. But \l could probably show dropped databases more prominently? We don't really have a good place to for database specific code. dbcommands.[ch] are for commands (duh), but already contain a bunch of functions that don't really belong there. Seems we should add a catalog/pg_database.c or catalog/database.c (tbh, I don't really know which we use for what). But that's probably for HEAD only. dbcommands.c's get_db_info() seems to have gone completely off the deep end. It returns information in 14 separate out parameters, and the variables for that need to all exhaustively be declared. And of course that differs heavily between releases, making it a pain to backpatch any change. ISTM we should just define a struct for the parameters - alternatively we could just return a copy of the pg_database tuple, but it looks like the variable-width attributes would make that *just* about a loss. I guess that's once more something better dealt with on HEAD, but damn, I'm not relishing having to deal with backpatching anything touching it - I think it might be reasonable to just open-code fetching datconnlimit :/. This patch is starting to be a bit big, particularly once adding tests for all the checks mentioned above - but I haven't heard of or thought of a better proposal :(. Greetings, Andres Freund [1] https://postgr.es/m/01020188d31d0a86-16af92c0-4466-4cb6-a2e8-0e5898aab800-000000%40eu-west-1.amazonses.com
Commits
-
pg_dump: tests: Correct test condition for invalid databases
- 881defde944c 16.1 landed
- 6a3b19bbefd7 11.22 landed
- fd7a114dbb4e 12.17 landed
- d1c76fdec375 13.13 landed
- 4dfb610822d5 14.10 landed
- 9dc3c5472ed9 15.5 landed
- 849d367ff9a2 17.0 landed
-
Handle DROP DATABASE getting interrupted
- f66403749df7 15.4 landed
- 1c38e7ae17b6 11.21 landed
- 034a9fcd2bb8 12.16 landed
- 81ce000067e3 13.12 landed
- d11efe830385 14.9 landed
- a4b4cc1d60f7 16.0 landed
- c66a7d75e652 17.0 landed