Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vmoni-0007qh-OT for pgsql-bugs@arkaria.postgresql.org; Sat, 30 Nov 2013 17:57:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Vmoni-0006tI-7l for pgsql-bugs@arkaria.postgresql.org; Sat, 30 Nov 2013 17:57:54 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Vmong-0006t9-6h for pgsql-bugs@postgresql.org; Sat, 30 Nov 2013 17:57:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VmonZ-0006lL-Ki for pgsql-bugs@postgresql.org; Sat, 30 Nov 2013 17:57:51 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id rAUHvi08025602; Sat, 30 Nov 2013 12:57:44 -0500 From: Tom Lane To: Oliver Seemann cc: pgsql-bugs@postgresql.org Subject: Re: Update with subselect sometimes returns wrong result In-reply-to: References: Comments: In-reply-to Oliver Seemann message dated "Sat, 30 Nov 2013 00:08:14 +0100" Date: Sat, 30 Nov 2013 12:57:44 -0500 Message-ID: <25601.1385834264@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) 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 Oliver Seemann writes: > Given the following table: > CREATE TABLE t1 (id INTEGER); > INSERT INTO t1 VALUES (0), (1); > Then the following UPDATE should return exactly one row: > UPDATE t1 SET id = t1.id > FROM (SELECT id FROM t1 LIMIT 1 FOR UPDATE) AS subset > WHERE t1.id = subset.id > RETURNING t1.id > And it does so, most of of the time. But when run repeatedly in a loop like > in the attached script, then it will occasionally return 2 rows with two > different id values, something the LIMIT 1 should prevent. In my tests it > took from anywhere between 0 to 10 minutes and on average 1 to 2 minutes to > trigger the problem. I failed to reproduce the claimed misbehavior in git tip of any active branch. I'd like to think this means we fixed the problem in the last two months, but I don't see anything that looks like a promising candidate in the commit logs. Perhaps there is some important contributing factor you've not mentioned --- nondefault postgresql.conf settings, for instance. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs