Re: BUG #5412: test case produced, possible race condition. - Mailing list pgsql-bugs

From Rusty Conover
Subject Re: BUG #5412: test case produced, possible race condition.
Date
Msg-id E677BD26-B101-4CA4-A01E-93BE16718B87@infogears.com
Whole thread Raw
In response to Re: BUG #5412: test case produced, possible race condition.  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
List pgsql-bugs
On Apr 14, 2010, at 7:10 AM, Heikki Linnakangas wrote:

> 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 t=
he crash on my box consistently.
>>=20
>> The script forks two different types of processes:
>>=20
>> #1 - begin transaction, create a few temp tables and analyze them in a t=
ransaction, commit (running in database foobar_1)
>> #2 - begin transaction, truncate table, insert records into table from s=
elect in a transaction, commit (running in database foobar_2)
>>=20
>> I setup the process to have 10 instances of task #1 and 1 instance of ta=
sk #2.
>>=20
>> Running this script causes the crash of postgres within seconds on my bo=
x.
>=20
> Thanks, that script crashes on my laptop too, with assertions enabled.
>=20
> According to the comments above RelationClearRelation(), if it's called
> with 'rebuild=3Dtrue', 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.
>=20
> 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?



Hi Heikki,

This patch allows my machine to run the script without crashing, so its wor=
king for me as well.

Many thanks,

Rusty
--
Rusty Conover
rconover@infogears.com
InfoGears Inc / GearBuyer.com / FootwearBuyer.com
http://www.infogears.com
http://www.gearbuyer.com
http://www.footwearbuyer.com

pgsql-bugs by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: Can you please let me know?
Next
From: Tom Lane
Date:
Subject: Re: BUG #5412: test case produced, possible race condition.