Re: Avoiding deadlocks ...

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <josh(at)agliodbs(dot)com>,<pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Avoiding deadlocks ...
Date: 2010-08-20 12:28:50
Message-ID: 4C6E2EB30200002500034963@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Josh Berkus wrote:

>> Two sessions, in transaction:
>>
>> Process A Process B
>>
>> update session where id = X;
>> update order where orderid = 5;
>> update order where orderid = 5;
>> update order where orderid = 5;
>> ... deadlock error.
>
> Johto on IRC pointed out I left something out of the above:
> "session" is referenced in an FK by "orders", and session = X is
> related to orderid = 5.

The patch I'm offering implements the SSI techniques published by
Michael Cahill, et al. Those techniques basically allow the current
snapshot isolation to run as it currently does, but monitors for
read/write conflicts to generate a new type of serialization failure
when a cycle becomes possible which could create an anomaly. There
are no read/write conflict cycles in your example, so it would behave
just as REPEATABLE READ and SERIALIZABLE now behave -- you get a
deadlock which rolls back one of the transactions.

I don't see how SSI can be modified to generate some other form of
serialization failure here, but I'm always open to suggestions.

-Kevin

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2010-08-20 12:45:08 Re: small smgrcreate cleanup patch
Previous Message Thom Brown 2010-08-20 12:16:44 Re: Why assignment before return?