Re: We need to rethink relation cache entry rebuild

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: We need to rethink relation cache entry rebuild
Date: 2010-01-10 23:57:44
Message-ID: 4389.1263167864@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> Basically I think we have to fix this by ensuring that an error escape
> can't occur while a relcache entry is in a partially rebuilt state.

Attached is a draft patch for this. In addition to fixing the stated
problem, it also takes care of a thinko that I found along the way:
RelationClearRelation assumes that any rd_indexprs or rd_indpred trees
can be freed by deleting the rd_indexcxt context, as the comments in
rel.h imply. But actually the code that loads those fields was putting
the trees directly into CacheMemoryContext, meaning that a cache flush
on an index that has expressions or a predicate would result in a
session-lifespan memory leak.

I think this is not too complicated to back-patch --- if anything the
logic is simpler than before. Comments?

regards, tom lane

Attachment Content-Type Size
relcache-rebuild-fix.patch text/x-patch 21.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2010-01-11 00:05:47 Re: Feature patch 1 for plperl [PATCH]
Previous Message David E. Wheeler 2010-01-10 23:44:31 Re: Feature patch 1 for plperl [PATCH]