From: Bruce Momjian <bruce@momjian.us>
To: Tim Channell <tim.channell@gmail.com>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: Greg Stark <stark@mit.edu>
Cc: PostgreSQL Bugs <pgsql-bugs@postgresql.org>
Subject: Re: BUG #10315: Transactions seem to be releasing locks early?
Date: Thu, 15 May 2014 14:50:40 -0400
Message-ID: <20140515185040.GF25053@momjian.us> (raw)
In-Reply-To: <CANqM=LQsEyJFWOmfQDH8rwu8oEM2qeEfBS_Pg649ZraJVqfioA@mail.gmail.com>
References: <20140513205137.11846.86900@wrigleys.postgresql.org>
<CAM-w4HNHh7qj=45cq=b2iH4xb+mD5HcvzmoirZ2AW3o8X4Y0=g@mail.gmail.com>
<CAB7nPqRa+Xwy-kMmeNEyYiEc1aCNRSLv=kmufkOcSCZBcE1pPQ@mail.gmail.com>
<CANqM=LQsEyJFWOmfQDH8rwu8oEM2qeEfBS_Pg649ZraJVqfioA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On Wed, May 14, 2014 at 12:15:13PM -0400, Tim Channell wrote:
> Here's the relevant documentation:
>
> However, such a target row might have already been updated (or deleted or
> locked) by another concurrent transaction by the time it is found. In this
> case, the would-be updater will wait for the first updating transaction to
> commit or roll back (if it is still in progress)... If the first updater
> commits, the second updater will ignore the row if the first updater deleted
> it, otherwise it will attempt to apply its operation to the updated version of
> the row. The search condition of the command (the WHERE clause) is re-evaluated
> to see if the updated version of the row still matches the search condition. If
> so, the second updater proceeds with its operation using the updated version of
> the row
I think you want to read about this example:
http://www.postgresql.org/docs/9.3/static/transaction-iso.html#XACT-READ-COMMITTED
BEGIN;
UPDATE website SET hits = hits + 1;
-- run from another session: DELETE FROM website WHERE hits = 10;
COMMIT;
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: bruce@momjian.us, tim.channell@gmail.com, michael.paquier@gmail.com, stark@mit.edu
Subject: Re: BUG #10315: Transactions seem to be releasing locks early?
In-Reply-To: <20140515185040.GF25053@momjian.us>
References: <20140513205137.11846.86900@wrigleys.postgresql.org> <CAM-w4HNHh7qj=45cq=b2iH4xb+mD5HcvzmoirZ2AW3o8X4Y0=g@mail.gmail.com> <CAB7nPqRa+Xwy-kMmeNEyYiEc1aCNRSLv=kmufkOcSCZBcE1pPQ@mail.gmail.com> <CANqM=LQsEyJFWOmfQDH8rwu8oEM2qeEfBS_Pg649ZraJVqfioA@mail.gmail.com> <20140515185040.GF25053@momjian.us>
* 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