From: Andrew Sullivan <ajs@crankycanuck.ca>
To: pgsql-sql@postgresql.org
Subject: Re: Changing the transaction isolation level within the stored
Date: Thu, 26 Jan 2006 11:39:02 -0500
Message-ID: <20060126163902.GB4836@phlogiston.dyndns.org> (raw)
In-Reply-To: <43D8C5CF.6030000@logix-tt.com>
References: <1138198348.8828.32.camel@localhost.localdomain>
<43D79132.9050900@logix-tt.com>
<1138259463.16164.4.camel@localhost.localdomain>
<43D8999E.9090907@logix-tt.com>
<20060126113902.GB3995@phlogiston.dyndns.org>
<43D8C5CF.6030000@logix-tt.com>
On Thu, Jan 26, 2006 at 01:51:27PM +0100, Markus Schaber wrote:
> Hmm, are you shure that this is correct? The delete will always delete 0
> rows.
Quite, and no it won't. The contrived example is actually a
simplification of a case one of our developers implemented. The
conflict is on the updates. Two concurrent transactions likely
wouldn't be enough to cause it on a fast system, but multiple ones
for sure will.
The problem is that the updates have to wait for one another to
complete in order to know what result they can use, but then the
_other_ contention on the other table causes them to have to wait for
one another there. I don't think anybody would have gone to the
trouble of putting in deadlock detection if the only way to deadlock
was to trip over yourself with manual locking: presumably, if you're
issuing locks by hand, you either know what you're doing or get what
you deserve.
> Depending on the transaction isolation level and exact timings,
> colliding queries may lead to different results or even one transaction
> aborted, but there is no deadlock under MVCC.
>
> Not needing such locks is the whole point in using MVCC at all.
I think you don't have a clear idea of what locks are necessary for
updates. Write operations on a row must block other write operations
on the same row. If more than one transaction needs the same kinds
of locks on two different tables, but attempts to get those locks in
the opposite order, you are all but guaranteed a deadlock. MVCC
helps, but it can't avoid locking the same data when that data is
being updated.
A
--
Andrew Sullivan | ajs@crankycanuck.ca
In the future this spectacle of the middle classes shocking the avant-
garde will probably become the textbook definition of Postmodernism.
--Brad Holland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: ajs@crankycanuck.ca
Subject: Re: Changing the transaction isolation level within the stored
In-Reply-To: <20060126163902.GB4836@phlogiston.dyndns.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox