pgsql: Improve lookup_type_cache() handling on out-of-memory errors

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Improve lookup_type_cache() handling on out-of-memory errors
Date: 2026-07-22 00:52:31
Message-ID: E1wmLCJ-00000000ElS-0Ylc@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Improve lookup_type_cache() handling on out-of-memory errors

If an error happens during the initialization of the TYPEOID catcache,
as part of lookup_type_cache(), the error handling of that lookup would
cause an assertion failure via finalize_in_progress_typentries(), called
during error recovery, the presence of an in-progress type OID causing
a catcache initialization outside of a transaction context.

The in-progress list is now delayed to happen after the initial entry
lookup. Alexander Lakhin has found a fancy way to reproduce the
problem, with the injection of probabilistic memory allocation failures.

This problem is unlikely going to show up in practice. Like the other
changes of this kind, no backpatch is done.

Reported-by: Alexander Lakhin <exclusion(at)gmail(dot)com>
Author: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
Discussion: https://postgr.es/m/95c64dc2-3abe-4f4e-b285-4c681f565d9f@gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ccfd4b683867a5eded09a82b624992c87396d02d

Modified Files
--------------
src/backend/utils/cache/typcache.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Previous Message Michael Paquier 2026-07-21 23:15:59 pgsql: Add new pgstats routine to split pending data setup