]> granicus.if.org Git - postgresql/commitdiff
Fix a tiny memory leak (one List header) in RelationCacheInvalidate().
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 19 Jan 2006 00:27:27 +0000 (00:27 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 19 Jan 2006 00:27:27 +0000 (00:27 +0000)
This is utterly insignificant in normal operation, but it becomes a
problem during cache inval stress testing.  The original coding in fact
had no leak --- the 8.0 List rewrite created the issue.  I wonder whether
list_concat should pfree the discarded header?

src/backend/utils/cache/relcache.c

index e0616b45a2f9a4f7ed66bc06bf06b17a345281ce..ec9e20320d2c4a611eb2e48e19b62c3f9e1a8fa0 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.230.2.1 2005/11/22 18:23:23 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.230.2.2 2006/01/19 00:27:27 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1786,8 +1786,6 @@ RelationCacheInvalidate(void)
                }
        }
 
-       rebuildList = list_concat(rebuildFirstList, rebuildList);
-
        /*
         * Now zap any remaining smgr cache entries.  This must happen before we
         * start to rebuild entries, since that may involve catalog fetches which
@@ -1796,6 +1794,12 @@ RelationCacheInvalidate(void)
        smgrcloseall();
 
        /* Phase 2: rebuild the items found to need rebuild in phase 1 */
+       foreach(l, rebuildFirstList)
+       {
+               relation = (Relation) lfirst(l);
+               RelationClearRelation(relation, true);
+       }
+       list_free(rebuildFirstList);
        foreach(l, rebuildList)
        {
                relation = (Relation) lfirst(l);