Re: WIP: generalized index constraints - Mailing list pgsql-hackers

From Tom Lane
Subject Re: WIP: generalized index constraints
Date
Msg-id 22968.1253464310@sss.pgh.pa.us
Whole thread Raw
In response to Re: WIP: generalized index constraints  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: WIP: generalized index constraints
List pgsql-hackers
Jeff Davis <pgsql@j-davis.com> writes:
> On Sat, 2009-09-19 at 18:00 -0400, Tom Lane wrote:
>> Well, you can't do it *exactly* the same way btree does, but what
>> I would envision is first insert the index tuple and then do a
>> dirty-snapshot search for conflicting tuples.  The interlock against
>> conflicting concurrent inserts doesn't need all this new infrastructure
>> you propose; just wait to see if conflicting transactions commit, same
>> as we do now.  And I do maintain that that sort of code has a high risk
>> of undetected bugs.

> How do you prevent deadlocks in the following case?

> T1: inserts into index
> T2: inserts into index
> T1: checks index for conflicts, finds T2
> T2: checks index for conflicts, finds T1

You get a deadlock failure, because both transactions will wait for each
other.  So what?  It's an error in any case, and you can get a reported
deadlock in constraint-enforcement scenarios today (conflicting FK
changes, for instance).
        regards, tom lane


pgsql-hackers by date:

Previous
From: Jeff Davis
Date:
Subject: Re: operator exclusion constraints [was: generalized index constraints]
Next
From: Tom Lane
Date:
Subject: Re: operator exclusion constraints [was: generalized index constraints]