Fixed pg_class refcache leak when the meta tuple in pg_class in invalid.

Lists: pgsql-hackers
From: Ming Li <mli(at)apache(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Fixed pg_class refcache leak when the meta tuple in pg_class in invalid.
Date: 2016-11-25 09:36:56
Message-ID: CA+F1uf=aAMqBaZvzXcP=wLehsfoY5Wn5Wi=-eYeiUcBHQy9H8A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

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.

Attachment Content-Type Size
pg_class_relcache_leak.diff text/plain 527 bytes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ming Li <mli(at)apache(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fixed pg_class refcache leak when the meta tuple in pg_class in invalid.
Date: 2016-11-25 23:57:58
Message-ID: 1066.1480118278@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Ming Li <mli(at)apache(dot)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


From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Ming Li <mli(at)apache(dot)org>, PostgreSQL mailing lists <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fixed pg_class refcache leak when the meta tuple in pg_class in invalid.
Date: 2016-11-28 02:47:36
Message-ID: CAB7nPqQQXB0o4-HxxFMR9ArsuG5MWviStDc1fWZ-TTLWKcjw7w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Nov 26, 2016 at 8:57 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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