Fixed pg_class refcache leak when the meta tuple in pg_class in invalid.
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.
Attachments:
pg_class_relcache_leak.difftext/plain; charset=US-ASCII; name=pg_class_relcache_leak.diffDownload
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
Ming Li <mli@apache.org> writes:
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.
I'm confused. RelationBuildDesc doesn't open pg_class and shouldn't
be responsible for closing it either; both of those things happen in
ScanPgRelation, leaving no apparent scope for a leak such as you suggest.
Moreover, there's no variable named pg_class_relation in this whole file,
so your patch wouldn't even compile.
Could you show us a test case that provokes the warning you see?
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
On Sat, Nov 26, 2016 at 8:57 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
Could you show us a test case that provokes the warning you see?
Nothing to worry about IMO. Looking at the patch, there is no
pg_class_relation declared, so this would not even compile...
--
Michael
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers