Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YaonV-0006Rq-AF for pgsql-bugs@arkaria.postgresql.org; Wed, 25 Mar 2015 17:08:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YaonU-0007an-Pp for pgsql-bugs@arkaria.postgresql.org; Wed, 25 Mar 2015 17:08:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YaonT-0007ag-P0 for pgsql-bugs@postgresql.org; Wed, 25 Mar 2015 17:08:51 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YaonP-0003xR-Ol for pgsql-bugs@postgresql.org; Wed, 25 Mar 2015 17:08:50 +0000 Received: from intern.anarazel.de (unknown [12.172.250.194]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id EE084860001; Wed, 25 Mar 2015 18:08:44 +0100 (CET) Date: Wed, 25 Mar 2015 18:08:42 +0100 From: Andres Freund To: Jaimin Pan Cc: pgsql-bugs@postgresql.org Subject: Re: [Report Bug With Patch] Rel Cache Bug Message-ID: <20150325170842.GC451@alap3.anarazel.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Pg-Spam-Score: -4.2 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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