Skip site navigation (1) Skip section navigation (2)

Re: compiling with RELCACHE_FORCE_RELEASE doesn't pass regression

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: compiling with RELCACHE_FORCE_RELEASE doesn't pass regression
Date: 2010-09-01 23:55:45
Message-ID: 4109.1283385345@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
I wrote:
> Jeff Davis <pgsql(at)j-davis(dot)com> writes:
>> I have attached regression.diffs after a "make check". The diffs don't
>> look trivial, and actually look quite strange to me.

> Hmm, sorta looks like that breaks something related to checking for
> composite types.  That would be a bug.  Will look.

So here is the culprit:

#0  0x00000000007c08e7 in flush_rowtype_cache (type_id=49022) at typcache.c:531
#1  0x00000000007b4797 in RelationClearRelation (relation=0x7fc490ccebe0, 
    rebuild=0 '\000') at relcache.c:1929
#2  0x00000000007b4131 in RelationClose (relation=0x7fc490ccebe0)
    at relcache.c:1680
#3  0x0000000000472721 in relation_close (relation=0x7fc490ccebe0, lockmode=1)
    at heapam.c:1051
#4  0x00000000007c01fe in lookup_type_cache (type_id=49022, flags=64)
    at typcache.c:299
#5  0x00000000007c023f in lookup_rowtype_tupdesc_internal (type_id=49022, 
    typmod=-1, noError=0 '\000') at typcache.c:321
#6  0x00000000007c03e7 in lookup_rowtype_tupdesc_copy (type_id=49022, 
    typmod=-1) at typcache.c:395
#7  0x00000000007cd087 in get_expr_result_type (expr=0x1395d08, 
    resultTypeId=0x0, resultTupleDesc=0x7fffbd6e5830) at funcapi.c:256

lookup_type_cache() opens the relcache entry to copy its tupdesc, does
so, and closes the relcache entry again.  But then (if
RELCACHE_FORCE_RELEASE is on) we blow away the relcache entry ...
and RelationClearRelation carefully reaches around and blows away
the tupdesc in the typcache too!

So that's overly aggressive, but I'm not sure what's a simple fix for
it.  If we just take out that flush_rowtype_cache call in
RelationClearRelation, I think we run the risk of the typcache not being
flushed when it needs to be, namely when an ALTER TABLE changes the
table's rowtype at an instant when some particular backend doesn't
have an active relcache entry for it.

Probably the best fix would be to make typcache flushing fully
independent of the relcache, but that would mean making sure that all
ALTER TABLE variants that affect the rowtype will issue an explicit
typcache flush.  That seems a bit too invasive to be back-patchable.
I'm not entirely sure this sort of failure can occur without
RELCACHE_FORCE_RELEASE, but I'm definitely not sure it can't, so a
backpatchable fix would be nice.

Thoughts?

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Bruce MomjianDate: 2010-09-01 23:56:45
Subject: Re: Fix for pg_upgrade's forcing pg_controldata into English
Previous:From: Robert HaasDate: 2010-09-01 23:26:52
Subject: Re: "serializable" in comments and names

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group