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 <[email protected]>
Author: Matthias van de Meent <[email protected]>
Discussion: https://postgr.es/m/[email protected]

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(-)

Reply via email to