v17-0001-Update-header-comment-for-lookup_type_cache.patch

application/octet-stream

Filename: v17-0001-Update-header-comment-for-lookup_type_cache.patch
Type: application/octet-stream
Part: 0
Message: Re: type cache cleanup improvements

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v17-0001
Subject: Update header comment for lookup_type_cache()
File+
src/backend/utils/cache/typcache.c 9 0
From d624b14c9a4bd93426a5e475d4503589927ef2ae Mon Sep 17 00:00:00 2001
From: Alexander Korotkov <akorotkov@postgresql.org>
Date: Fri, 13 Sep 2024 02:10:04 +0300
Subject: [PATCH v17 1/2] Update header comment for lookup_type_cache()

Describe the way we handle concurrent invalidation messages.
---
 src/backend/utils/cache/typcache.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/backend/utils/cache/typcache.c b/src/backend/utils/cache/typcache.c
index 2ec136b7d30..11382547ec0 100644
--- a/src/backend/utils/cache/typcache.c
+++ b/src/backend/utils/cache/typcache.c
@@ -351,6 +351,15 @@ type_cache_syshash(const void *key, Size keysize)
  * invalid.  Note however that we may fail to find one or more of the
  * values requested by 'flags'; the caller needs to check whether the fields
  * are InvalidOid or not.
+ *
+ * Note that while filling TypeCacheEntry we might process concurrent
+ * invalidation messages, causing our not-yet-filled TypeCacheEntry to be
+ * invalidated.  In this case, we typically only clear flags while values are
+ * still available for the caller.  It's expected that the caller holds
+ * enough locks on type-depending objects that the values are still relevant.
+ * It's also important that the tupdesc is filled in the last for
+ * TYPTYPE_COMPOSITE. So, it can't get invalidated during the
+ * lookup_type_cache() call.
  */
 TypeCacheEntry *
 lookup_type_cache(Oid type_id, int flags)
-- 
2.39.5 (Apple Git-154)