Hi all,

In some cases the meta tuple in pg_class for a specific relation is
invalid, which will cause relcache leak, and then report warning:
WARNING: relcache reference leak: relation "pg_class" not closed.

The diff file in the attachment can fix this problem.
diff --git a/src/backend/utils/cache/relcache.c 
b/src/backend/utils/cache/relcache.c
index 79e0b1f..6485fc4 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -951,7 +951,11 @@ RelationBuildDesc(Oid targetRelId, bool insertIt)
         * if no such tuple exists, return NULL
         */
        if (!HeapTupleIsValid(pg_class_tuple))
+       {
+               if(RelationIsValid(pg_class_relation))
+                       heap_close(pg_class_relation, AccessShareLock);
                return NULL;
+       }
 
        /*
         * get information from the pg_class_tuple
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to