Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7eb5428

Browse files
committed
During CatCacheRemoveCList, we must now remove any members that are
dead and have become unreferenced. Before 8.1, such members were left for AtEOXact_CatCache() to clean up, but now AtEOXact_CatCache isn't supposed to have anything to do. In an assert-enabled build this bug leads to an assertion failure at transaction end, but in a non-assert build the dead member is effectively just a small memory leak. Per report from Jeremy Drake.
1 parent 0a8510e commit 7eb5428

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/backend/utils/cache/catcache.c

+19-1
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.126 2005/11/22 18:17:24 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/cache/catcache.c,v 1.127 2006/01/07 21:16:10 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -356,7 +356,16 @@ CatCacheRemoveCTup(CatCache *cache, CatCTup *ct)
356356
Assert(ct->my_cache == cache);
357357

358358
if (ct->c_list)
359+
{
360+
/*
361+
* The cleanest way to handle this is to call CatCacheRemoveCList,
362+
* which will recurse back to me, and the recursive call will do the
363+
* work. Set the "dead" flag to make sure it does recurse.
364+
*/
365+
ct->dead = true;
359366
CatCacheRemoveCList(cache, ct->c_list);
367+
return; /* nothing left to do */
368+
}
360369

361370
/* delink from linked lists */
362371
DLRemove(&ct->lrulist_elem);
@@ -375,6 +384,8 @@ CatCacheRemoveCTup(CatCache *cache, CatCTup *ct)
375384
* CatCacheRemoveCList
376385
*
377386
* Unlink and delete the given cache list entry
387+
*
388+
* NB: any dead member entries that become unreferenced are deleted too.
378389
*/
379390
static void
380391
CatCacheRemoveCList(CatCache *cache, CatCList *cl)
@@ -391,6 +402,13 @@ CatCacheRemoveCList(CatCache *cache, CatCList *cl)
391402

392403
Assert(ct->c_list == cl);
393404
ct->c_list = NULL;
405+
/* if the member is dead and now has no references, remove it */
406+
if (
407+
#ifndef CATCACHE_FORCE_RELEASE
408+
ct->dead &&
409+
#endif
410+
ct->refcount == 0)
411+
CatCacheRemoveCTup(cache, ct);
394412
}
395413

396414
/* delink from linked list */

0 commit comments

Comments
 (0)