Re: [bug] relcache leaks in get_object_address

Lists: pgsql-hackers
From: Kohei KaiGai <kaigai(at)kaigai(dot)gr(dot)jp>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: PgHacker <pgsql-hackers(at)postgresql(dot)org>
Subject: [bug] relcache leaks in get_object_address
Date: 2011-10-13 15:10:34
Message-ID: CADyhKSXFm6yJpJnHNAFecNMc8eq9KpWV7q05efjRgsZ_Vubxkw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I noticed a problem of get_object_address() with missing_ok = true.

When we try to solve the name of nonexistent rule/trigger/constraint on
a particular existing table, get_object_address_relobject() opens the
relation, but address.objectId = InvalidOid shall be set.

I think it should be closed if the queried object was missing, although
existing code does not invoke get_object_address() with missing_ok = true.

Thanks,
--
KaiGai Kohei <kaigai(at)kaigai(dot)gr(dot)jp>


From: Kohei KaiGai <kaigai(at)kaigai(dot)gr(dot)jp>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: PgHacker <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [bug] relcache leaks in get_object_address
Date: 2011-10-13 16:27:12
Message-ID: CADyhKSUy4RPFumXp=-YOxm+nTejef7VPHaWtvSMsCovuh3=iiQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

The attached patch fixes this problem.
Unfortunately, we have no code that invokes get_object_address()
with missing_ok = true now, so please apply a couple of patches
to rework DROP statement of mine.

DROP TRIGGER no_such_trigger ON existing_table;

shall cause a relcache reference leaks, without this patch.

Thanks,

2011/10/13 Kohei KaiGai <kaigai(at)kaigai(dot)gr(dot)jp>:
> I noticed a problem of get_object_address() with missing_ok = true.
>
> When we try to solve the name of nonexistent rule/trigger/constraint on
> a particular existing table, get_object_address_relobject() opens the
> relation, but address.objectId = InvalidOid shall be set.
>
> I think it should be closed if the queried object was missing, although
> existing code does not invoke get_object_address() with missing_ok = true.
>
> Thanks,
> --
> KaiGai Kohei <kaigai(at)kaigai(dot)gr(dot)jp>
>

--
KaiGai Kohei <kaigai(at)kaigai(dot)gr(dot)jp>

Attachment Content-Type Size
pgsql-v9.2-fix-relcache-leaks-in-get_object_address_relobject.patch application/octet-stream 953 bytes

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Kohei KaiGai <kaigai(at)kaigai(dot)gr(dot)jp>
Cc: PgHacker <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [bug] relcache leaks in get_object_address
Date: 2011-10-14 15:41:25
Message-ID: CA+TgmoZ30Cr-s02h97vz=8v+vj-FdTtWu6hOAyzBe3w-YopwvA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Oct 13, 2011 at 12:27 PM, Kohei KaiGai <kaigai(at)kaigai(dot)gr(dot)jp> wrote:
> The attached patch fixes this problem.
> Unfortunately, we have no code that invokes get_object_address()
> with missing_ok = true now, so please apply a couple of patches
> to rework DROP statement of mine.
>
> DROP TRIGGER no_such_trigger ON existing_table;
>
> shall cause a relcache reference leaks, without this patch.

We could argue that that's a bug in your drop reworks rather than the
existing code, but I'm willing to go along with this approach, so,
committed.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company