postgresql/src/backend
Noah Misch 0dfbd191a9 Assert lack of hazardous buffer locks before possible catalog read.
Commit 0bada39c83 fixed a bug of this kind,
which existed in all branches for six days before detection.  While the
probability of reaching the trouble was low, the disruption was extreme.  No
new backends could start, and service restoration needed an immediate
shutdown.  Hence, add this to catch the next bug like it.

The new check in RelationIdGetRelation() suffices to make autovacuum detect
the bug in commit 243e9b40f1 that led to commit
0bada39.  This also checks in a number of similar places.  It replaces each
Assert(IsTransactionState()) that pertained to a conditional catalog read.

Back-patch to v14 - v17.  This a back-patch of commit
f4ece891fc (from before v18 branched) to
all supported branches, to accompany the back-patch of commits 243e9b4
and 0bada39.  For catalog indexes, the bttextcmp() behavior that
motivated IsCatalogTextUniqueIndexOid() was v18-specific.  Hence, this
back-patch doesn't need that or its correction from commit
4a4ee0c2c1.

Reported-by: Alexander Lakhin <exclusion@gmail.com>
Discussion: https://postgr.es/m/20250410191830.0e.nmisch@google.com
Discussion: https://postgr.es/m/10ec0bc3-5933-1189-6bb8-5dec4114558e@gmail.com
Backpatch-through: 14-17
2025-12-16 16:13:56 -08:00
..
access WAL-log inplace update before revealing it to other sessions. 2025-12-16 16:13:56 -08:00
bootstrap Rethink definition of pg_attribute.attcompression. 2021-05-27 13:24:27 -04:00
catalog For inplace update, send nontransactional invalidations. 2025-12-16 16:13:56 -08:00
commands Add note about CreateStatistics()'s selective use of check_rights. 2025-11-14 13:20:09 -06:00
executor Update obsolete comment in ExecScanReScan(). 2025-11-06 12:25:04 +09:00
foreign Restrict accesses to non-system views and foreign tables during pg_dump. 2024-08-05 06:05:23 -07:00
jit Fix allocation formula in llvmjit_expr.c 2025-12-11 10:25:51 +09:00
lib Accommodate very large dshash tables. 2024-12-17 15:24:45 -06:00
libpq Fix build breakage on Solaris-alikes with late-model GCC. 2025-07-23 15:44:29 -04:00
main Fix elog(FATAL) before PostmasterMain() or just after fork(). 2024-12-10 13:52:02 -08:00
nodes Build whole-row Vars the same way during parsing and planning. 2025-03-12 11:47:19 -04:00
optimizer Allow indexscans on partial hash indexes with implied quals. 2025-11-27 13:09:59 -05:00
parser Don't allow CTEs to determine semantic levels of aggregates. 2025-11-18 12:56:55 -05:00
partitioning Fix creation of partition descriptor during concurrent detach+drop 2024-08-12 18:17:56 -04:00
po Translation updates 2025-11-10 13:06:35 +01:00
port Don't treat EINVAL from semget() as a hard failure. 2025-08-13 11:59:47 -04:00
postmaster Fix snapshot handling bug in recent BRIN fix 2025-11-04 20:31:43 +01:00
regex Fix recently-exposed portability issue in regex optimization. 2024-11-17 14:14:06 -05:00
replication For inplace update, send nontransactional invalidations. 2025-12-16 16:13:56 -08:00
rewrite Avoid rewriting data-modifying CTEs more than once. 2025-11-29 12:34:45 +00:00
snowball Avoid null pointer dereference crash after OOM in Snowball stemmers. 2025-02-18 21:24:12 -05:00
statistics Fix security checks in selectivity estimation functions. 2025-08-11 09:12:09 +01:00
storage Assert lack of hazardous buffer locks before possible catalog read. 2025-12-16 16:13:56 -08:00
tcop Check for CREATE privilege on the schema in CREATE STATISTICS. 2025-11-10 09:00:00 -06:00
tsearch Clear errno before calling strtol() in spell.c. 2025-03-08 11:24:57 -05:00
utils Assert lack of hazardous buffer locks before possible catalog read. 2025-12-16 16:13:56 -08:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Use sort_template.h for qsort_tuple() and qsort_ssup(). 2021-03-03 17:02:32 +13:00
nls.mk Translation updates 2021-09-20 16:23:13 +02:00