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

Re: BUG #5412: test case produced, possible race condition.

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Rusty Conover <rconover(at)infogears(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5412: test case produced, possible race condition.
Date: 2010-04-14 11:10:02
Message-ID: 4BC5A28A.5060902@enterprisedb.com (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-hackers
Rusty Conover wrote:
> It seems like this is a race condition cause by the system catalog cache not being locked properly. I've included a perl script below that causes the crash on my box consistently.
> 
> The script forks two different types of processes:
> 
> #1 - begin transaction, create a few temp tables and analyze them in a transaction, commit (running in database foobar_1)
> #2 - begin transaction, truncate table, insert records into table from select in a transaction, commit (running in database foobar_2)
> 
> I setup the process to have 10 instances of task #1 and 1 instance of task #2.
> 
> Running this script causes the crash of postgres within seconds on my box.

Thanks, that script crashes on my laptop too, with assertions enabled.

According to the comments above RelationClearRelation(), if it's called
with 'rebuild=true', the caller should hold a lock on the relation, i.e
refcnt > 0. That's not the case in RelationFlushRelation() when it
rebuilds a new relcache entry.

Attached patch should fix that, by incrementing the reference count
while the entry is rebuilt. It also adds an Assertion in
RelationClearRelation() to check that the refcnt is indeed > 0.
Comments?

-- 
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com

Attachment: fix-relcache-crash-1.patch
Description: text/x-diff (1.9 KB)

In response to

Responses

pgsql-hackers by date

Next:From: Craig RingerDate: 2010-04-14 11:19:49
Subject: [Fwd: [BUGS] build error: strlcat/strlcpy used from heimdal libroken.so]
Previous:From: Robert HaasDate: 2010-04-14 11:07:34
Subject: Re: master in standby mode croaks

pgsql-bugs by date

Next:From: Craig RingerDate: 2010-04-14 11:41:44
Subject: Re: Bug in CREATE FUNCTION with character type (CONFIRMED BUG)
Previous:From: cool showerDate: 2010-04-14 11:02:49
Subject: BUG #5421: pg_attribute broken

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