Re: Re: Problem Observed in behavior of Create Index Concurrently and Hot Update - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Re: Problem Observed in behavior of Create Index Concurrently and Hot Update
Date
Msg-id 20121127101843.GB3989@awork2.anarazel.de
Whole thread Raw
In response to Re: Re: Problem Observed in behavior of Create Index Concurrently and Hot Update  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Re: Problem Observed in behavior of Create Index Concurrently and Hot Update  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 2012-11-26 16:39:39 -0500, Tom Lane wrote:
> Andres Freund <andres@2ndquadrant.com> writes:
> > On 2012-10-31 11:41:37 +0530, Amit Kapila wrote:
> >> There seems to be a problem in behavior of Create Index Concurrently and Hot
> >> Update in HEAD code .
>
> > At pgcon.it I had a chance to discuss with Simon how to fix this
> > bug. Please check the attached patches - and their commit messages - for
> > the fix and some regression tests.
>
> I looked at this a bit.  I am very unhappy with the proposed kluge to
> open indexes NoLock in some places.  Even if that's safe today, which
> I don't believe in the least, any future change in this area could break
> it.

I am not happy with it either. But I failed to see a better way. Note
that in most of the cases a lock actually is acquired shortly
afterwards, just a ->indisvalid or an ->indisready check away. The only
exception is RelationGetIndexAttrBitmap which actually needs to look at
!indisvalid && !indisready indexes because of HOT. All the former cases
could just do a syscache lookup beforehand and skip if it doesn't match
their criterion. I wasn't sure about the (performance, notational)
overhead of doing a second syscache lookup in those paths.

Note that any ->indisvalid/indisready change is protected by waiting for
all concurrent backends to finish, so I don't think the separate
syscache lookup/index_open would be a problem.

For RelationGetIndexAttrBitmap, I don't really see a point in the locks
acquired - after all were not protecting the RelationGetIndexList
either.

Greetings,

Andres

--Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: MySQL search query is not executing in Postgres DB
Next
From: Dimitri Fontaine
Date:
Subject: Re: Materialized views WIP patch