Skip to content

Commit 649e856

Browse files
committed
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).
1 parent 91215f6 commit 649e856

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/backend/utils/cache/catcache.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.140 2008/01/01 19:45:53 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.141 2008/03/05 17:01:26 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1781,13 +1781,13 @@ PrepareToInvalidateCacheTuple(Relation relation,
17811781

17821782
for (ccp = CacheHdr->ch_caches; ccp; ccp = ccp->cc_next)
17831783
{
1784+
if (ccp->cc_reloid != reloid)
1785+
continue;
1786+
17841787
/* Just in case cache hasn't finished initialization yet... */
17851788
if (ccp->cc_tupdesc == NULL)
17861789
CatalogCacheInitializeCache(ccp);
17871790

1788-
if (ccp->cc_reloid != reloid)
1789-
continue;
1790-
17911791
(*function) (ccp->id,
17921792
CatalogCacheComputeTupleHashValue(ccp, tuple),
17931793
&tuple->t_self,

0 commit comments

Comments
 (0)