From: Andres Freund <andres@2ndquadrant.com>
To: Jaimin Pan <jaimin.pan@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: [Report Bug With Patch] Rel Cache Bug
Date: Wed, 25 Mar 2015 18:08:42 +0100
Message-ID: <20150325170842.GC451@alap3.anarazel.de> (raw)
In-Reply-To: <CABP8UDQH3T=AMNvPd1e743HUt52TYQpciH-P2WEU7pY9nJkDwQ@mail.gmail.com>
References: <CABP8UDQH3T=AMNvPd1e743HUt52TYQpciH-P2WEU7pY9nJkDwQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Hi,
On 2015-03-25 21:59:17 +0800, Jaimin Pan wrote:
> I think there is a bug in rel cache rebuild of release 9.4.1.
> it also exists on some other release.
>
> the issue was introduced by 491dd4a97daa6b4de9ee8401ada10ad5da76af46
>
> -- a/src/backend/utils/cache/relcache.c
> +++ b/src/backend/utils/cache/relcache.c
> @@ -2166,9 +2166,9 @@ RelationClearRelation(Relation relation, bool rebuild)
> /* ... but actually, we don't have to update newrel->rd_rel
> */
> memcpy(relation->rd_rel, newrel->rd_rel, CLASS_TUPLE_SIZE);
> /* preserve old tupledesc and rules if no logical change */
> - if (keep_tupdesc)
> + if (!keep_tupdesc)
> SWAPFIELD(TupleDesc, rd_att);
> - if (keep_rules)
> + if (!keep_rules)
> {
> SWAPFIELD(RuleLock *, rd_rules);
> SWAPFIELD(MemoryContext, rd_rulescxt);
> diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
> index f6520a0..733860c 100644
> --- a/src/backend/utils/cache/relcache.c
> +++ b/src/backend/utils/cache/relcache.c
> @@ -2166,9 +2166,9 @@ RelationClearRelation(Relation relation, bool rebuild)
> /* ... but actually, we don't have to update newrel->rd_rel */
> memcpy(relation->rd_rel, newrel->rd_rel, CLASS_TUPLE_SIZE);
> /* preserve old tupledesc and rules if no logical change */
> - if (keep_tupdesc)
> + if (!keep_tupdesc)
> SWAPFIELD(TupleDesc, rd_att);
> - if (keep_rules)
> + if (!keep_rules)
> {
> SWAPFIELD(RuleLock *, rd_rules);
> SWAPFIELD(MemoryContext, rd_rulescxt);
Why do you think this is broken? While certainly not the prettiest code
around it looks ok to me. What it does is to keep the other entries data
around. Which we want if it's possibly referenced.
Greetings,
Andres Freund
--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: andres@2ndquadrant.com, jaimin.pan@gmail.com
Subject: Re: [Report Bug With Patch] Rel Cache Bug
In-Reply-To: <20150325170842.GC451@alap3.anarazel.de>
References: <CABP8UDQH3T=AMNvPd1e743HUt52TYQpciH-P2WEU7pY9nJkDwQ@mail.gmail.com> <20150325170842.GC451@alap3.anarazel.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox