postgresql/src/include/catalog
Andres Freund 034a9fcd2b Handle DROP DATABASE getting interrupted
Until now, when DROP DATABASE got interrupted in the wrong moment, the removal
of the pg_database row would also roll back, even though some irreversible
steps have already been taken. E.g. DropDatabaseBuffers() might have thrown
out dirty buffers, or files could have been unlinked. But we continued to
allow connections to such a corrupted database.

To fix this, mark databases invalid with an in-place update, just before
starting to perform irreversible steps. As we can't add a new column in the
back branches, we use pg_database.datconnlimit = -2 for this purpose.

An invalid database cannot be connected to anymore, but can still be
dropped.

Unfortunately we can't easily add output to psql's \l to indicate that some
database is invalid, it doesn't fit in any of the existing columns.

Add tests verifying that a interrupted DROP DATABASE is handled correctly in
the backend and in various tools.

Reported-by: Evgeny Morozov <postgresql3@realityexists.net>
Author: Andres Freund <andres@anarazel.de>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Reviewed-by: Thomas Munro <thomas.munro@gmail.com>
Discussion: https://postgr.es/m/20230509004637.cgvmfwrbht7xm7p6@awork3.anarazel.de
Discussion: https://postgr.es/m/20230314174521.74jl6ffqsee5mtug@awork3.anarazel.de
Backpatch: 11-, bug present in all supported versions
2023-07-13 13:03:36 -07:00
..
.gitignore Replace our traditional initial-catalog-data format with a better design. 2018-04-08 13:17:27 -04:00
binary_upgrade.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
catalog.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
catversion.h Straighten out leakproofness markings on text comparison functions. 2019-09-21 16:56:30 -04:00
dependency.h In extensions, don't replace objects not belonging to the extension. 2022-08-08 11:12:31 -04:00
duplicate_oids Update copyright for 2019 2019-01-02 12:44:25 -05:00
genbki.h Move the built-in conversions into the initial catalog data. 2019-01-03 19:47:53 -05:00
heap.h Preserve index data in pg_statistic across REINDEX CONCURRENTLY 2020-11-01 21:24:15 +09:00
index.h Fix possible crash during FATAL exit from reindexing. 2020-04-21 15:58:42 -04:00
indexing.h Rework the pg_statistic_ext catalog 2019-06-16 01:20:31 +02:00
Makefile Minor improvements for reformat_dat_file.pl. 2019-03-08 11:48:49 -05:00
namespace.h Avoid failure if autovacuum tries to access a just-dropped temp namespace. 2020-02-28 20:28:34 -05:00
objectaccess.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
objectaddress.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
opfam_internal.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
partition.h Fix more typos and inconsistencies in the tree 2019-06-17 16:13:16 +09:00
pg_aggregate.dat Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_aggregate.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
pg_am.dat tableam: introduce table AM infrastructure. 2019-03-06 09:54:38 -08:00
pg_am.h tableam: introduce table AM infrastructure. 2019-03-06 09:54:38 -08:00
pg_amop.dat GIN support for @@ and @? jsonpath operators 2019-04-01 18:08:52 +03:00
pg_amop.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_amproc.dat Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_amproc.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_attrdef.h Initial pgindent run for v12. 2019-05-22 12:55:34 -04:00
pg_attribute.h Generated columns 2019-03-30 08:15:57 +01:00
pg_auth_members.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_authid.dat Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_authid.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_cast.dat Add support for multivariate MCV lists 2019-03-27 18:32:18 +01:00
pg_cast.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_class.dat Generated columns 2019-03-30 08:15:57 +01:00
pg_class.h Correct comment and some documentation about REPLICA_IDENTITY_INDEX 2021-12-22 16:38:49 +09:00
pg_collation.dat Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_collation.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
pg_constraint.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
pg_control.h Fix WAL replay in presence of an incomplete record 2021-09-29 11:21:51 -03:00
pg_conversion.dat Move the built-in conversions into the initial catalog data. 2019-01-03 19:47:53 -05:00
pg_conversion.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
pg_database.dat Remove remaining hard-wired OID references in the initial catalog data. 2019-03-12 12:30:35 -04:00
pg_database.h Handle DROP DATABASE getting interrupted 2023-07-13 13:03:36 -07:00
pg_db_role_setting.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
pg_default_acl.h Initial pgindent run for v12. 2019-05-22 12:55:34 -04:00
pg_depend.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_description.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_enum.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
pg_event_trigger.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_extension.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_foreign_data_wrapper.h Fix more typos and inconsistencies in the tree 2019-06-17 16:13:16 +09:00
pg_foreign_server.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_foreign_table.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_index.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_inherits.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
pg_init_privs.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_language.dat Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_language.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_largeobject.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_largeobject_metadata.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_namespace.dat Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_namespace.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_opclass.dat Fix up handling of nondeterministic collations with pattern_ops opclasses. 2019-09-21 16:29:17 -04:00
pg_opclass.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_operator.dat Remove ambiguity for jsonb_path_match() and jsonb_path_exists() 2019-03-20 10:30:56 +03:00
pg_operator.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
pg_opfamily.dat Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_opfamily.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_partitioned_table.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_pltemplate.dat Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_pltemplate.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_policy.h Initial pgindent run for v12. 2019-05-22 12:55:34 -04:00
pg_proc.dat Straighten out leakproofness markings on text comparison functions. 2019-09-21 16:56:30 -04:00
pg_proc.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
pg_publication.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
pg_publication_rel.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_range.dat Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_range.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
pg_replication_origin.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_rewrite.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_seclabel.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_sequence.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_shdepend.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_shdescription.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_shseclabel.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_statistic.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_statistic_ext.h Rework the pg_statistic_ext catalog 2019-06-16 01:20:31 +02:00
pg_statistic_ext_data.h pgindent run prior to branching v12. 2019-07-01 12:37:52 -04:00
pg_subscription.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_subscription_rel.h Avoid direct C access to possibly-null pg_subscription_rel.srsublsn. 2020-07-21 11:40:46 -04:00
pg_tablespace.dat Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_tablespace.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_transform.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_trigger.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_ts_config.dat Remove remaining hard-wired OID references in the initial catalog data. 2019-03-12 12:30:35 -04:00
pg_ts_config.h Remove remaining hard-wired OID references in the initial catalog data. 2019-03-12 12:30:35 -04:00
pg_ts_config_map.dat Remove remaining hard-wired OID references in the initial catalog data. 2019-03-12 12:30:35 -04:00
pg_ts_config_map.h Remove remaining hard-wired OID references in the initial catalog data. 2019-03-12 12:30:35 -04:00
pg_ts_dict.dat Remove remaining hard-wired OID references in the initial catalog data. 2019-03-12 12:30:35 -04:00
pg_ts_dict.h Remove remaining hard-wired OID references in the initial catalog data. 2019-03-12 12:30:35 -04:00
pg_ts_parser.dat Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_ts_parser.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_ts_template.dat Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_ts_template.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_type.dat Do pre-release housekeeping on catalog data, and fix jsonpath send/recv. 2019-04-28 17:16:50 -04:00
pg_type.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
pg_user_mapping.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
reformat_dat_file.pl Minor improvements for reformat_dat_file.pl. 2019-03-08 11:48:49 -05:00
renumber_oids.pl Create a script that can renumber manually-assigned OIDs. 2019-03-12 10:50:48 -04:00
storage.h Revert "Skip WAL for new relfilenodes, under wal_level=minimal." 2020-03-22 09:24:13 -07:00
storage_xlog.h Fix several recently introduced issues around handling new relation forks. 2019-04-29 19:28:05 -07:00
toasting.h Fix toast rewrites in logical decoding. 2021-08-25 09:32:56 +05:30
unused_oids Initial pgperltidy run for v12. 2019-05-22 13:36:19 -04:00