From 742d6fe6b49edee01f5f6659aecb7b04a84a7fc4 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 5 Mar 2008 17:01:41 +0000 Subject: [PATCH] In PrepareToInvalidateCacheTuple, don't force initialization of catalog caches that we don't actually need to touch. This saves some trivial number of cycles and avoids certain cases of deadlock when doing concurrent VACUUM FULL on system catalogs. Per report from Gavin Roy. Backpatch to 8.2. In earlier versions, CatalogCacheInitializeCache didn't lock the relation so there's no deadlock risk (though that certainly had plenty of risks of its own). --- src/backend/utils/cache/catcache.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index de6c522c61..890efb4632 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -1781,13 +1781,13 @@ PrepareToInvalidateCacheTuple(Relation relation, for (ccp = CacheHdr->ch_caches; ccp; ccp = ccp->cc_next) { + if (ccp->cc_reloid != reloid) + continue; + /* Just in case cache hasn't finished initialization yet... */ if (ccp->cc_tupdesc == NULL) CatalogCacheInitializeCache(ccp); - if (ccp->cc_reloid != reloid) - continue; - (*function) (ccp->id, CatalogCacheComputeTupleHashValue(ccp, tuple), &tuple->t_self, -- 2.39.5