Re: Race conditions in relcache load (again)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Race conditions in relcache load (again)
Date: 2008-04-16 18:26:22
Message-ID: 14432.1208370382@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> I realized that we failed to plug all the gaps of this type,
> because relcache.c contains *internal* cache load/reload operations
> that aren't protected. In particular the LOAD_CRIT_INDEX macro
> calls invoke relcache load on indexes that aren't locked. So they'd
> be at risk from a concurrent REINDEX or similar on those system
> indexes. RelationReloadIndexInfo seems at risk as well.

On closer analysis, LOAD_CRIT_INDEX is clearly broken here, but the
other places I was worried about seem safe, because they are all
used to rebuild relcache entries that are being held open by
higher-level code; and the contract is that there should be a lock
protecting any open relcache entry.

I've committed a fix that adds locking to LOAD_CRIT_INDEX and adds
some comments about the other cases.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2008-04-16 18:26:39 Re: How to submit a patch
Previous Message Andrew Dunstan 2008-04-16 18:26:08 Re: How to submit a patch