Re: [PATCH] SQL assertions prototype - Mailing list pgsql-hackers

From Kevin Grittner
Subject Re: [PATCH] SQL assertions prototype
Date
Msg-id 1387382727.2613.YahooMailNeo@web162901.mail.bf1.yahoo.com
Whole thread Raw
In response to Re: [PATCH] SQL assertions prototype  (Heikki Linnakangas <hlinnakangas@vmware.com>)
List pgsql-hackers
Heikki Linnakangas <hlinnakangas@vmware.com> wrote:
>On 12/18/2013 01:39 PM, Andres Freund wrote:
>> On 2013-12-18 13:07:51 +0200, Heikki Linnakangas wrote:
>>> Here's another idea that doesn't involve SSI:
>>>
>>> At COMMIT, take a new snapshot and check that the assertion still passes
>>> with that snapshot. Now, there's a race condition, if another transaction is
>>> committing at the same time, and performs the same check concurrently. That
>>> race condition can be eliminated by holding an exclusive lock while running
>>> the assertion, until commit, effectively allowing the assertion to be
>>> checked by only one transaction at a time.
>>>
>>> I think that would work, and would be simple, although it wouldn't scale too
>>> well.
>>
>> It probably would also be very prone to deadlocks.
>
> Hmm, since this would happen at commit, you would know all the
> assertions that need to be checked at that point. You could check them
> e.g in Oid order to avoid deadlocks.

So you would actually serialize all COMMITs, or at least all which
had done anything which could affect the truth of an assertion?
That seems like it would work, but I suspect that it would be worse
for performance than SSI in many workloads, and better than SSI in
other workloads.  Maybe a GUC to determine which strategy is used?

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: 9.3 reference constraint regression
Next
From: Sawada Masahiko
Date:
Subject: Re: Logging WAL when updating hintbit