Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wl0jy-00027E-S7 for pgsql-bugs@arkaria.postgresql.org; Thu, 15 May 2014 18:50:51 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Wl0jy-0004NL-Bd for pgsql-bugs@arkaria.postgresql.org; Thu, 15 May 2014 18:50:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wl0jx-0004ND-OO for pgsql-bugs@postgresql.org; Thu, 15 May 2014 18:50:49 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wl0jq-0004l6-GC for pgsql-bugs@postgresql.org; Thu, 15 May 2014 18:50:49 +0000 Received: from bruce by momjian.us with local (Exim 4.72) (envelope-from ) id 1Wl0jo-0002B5-T9; Thu, 15 May 2014 14:50:40 -0400 Date: Thu, 15 May 2014 14:50:40 -0400 From: Bruce Momjian To: Tim Channell Cc: Michael Paquier , Greg Stark , PostgreSQL Bugs Subject: Re: BUG #10315: Transactions seem to be releasing locks early? Message-ID: <20140515185040.GF25053@momjian.us> References: <20140513205137.11846.86900@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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 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