Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WzSWm-00087p-LA for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Jun 2014 15:20:56 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WzSWm-0005ZX-1F for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Jun 2014 15:20:56 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1WzSRd-0005Lx-5G for pgsql-bugs@postgresql.org; Tue, 24 Jun 2014 15:15:37 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WzSRZ-0004yS-Ag for pgsql-bugs@postgresql.org; Tue, 24 Jun 2014 15:15:35 +0000 Received: by mail.anarazel.de (Postfix, from userid 108) id 44052500002; Tue, 24 Jun 2014 17:15:32 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from anarazel.de (p54AF4235.dip0.t-ipconnect.de [84.175.66.53]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id 46CF4500001; Tue, 24 Jun 2014 17:15:26 +0200 (CEST) Received: by anarazel.de (Postfix, from userid 1000) id CC8F61005BF; Tue, 24 Jun 2014 17:15:25 +0200 (CEST) Date: Tue, 24 Jun 2014 17:15:25 +0200 From: Andres Freund To: pinker@onet.eu Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #10748: xmax is not resetting properly with FOR UPDATE Message-ID: <20140624151525.GB24114@awork2.anarazel.de> References: <20140624142926.2618.16610@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20140624142926.2618.16610@wrigleys.postgresql.org> 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 Hi, On 2014-06-24 14:29:26 +0000, pinker@onet.eu wrote: > The following bug has been logged on the website: > > Bug reference: 10748 > Logged by: Alicja Kucharczyk > Email address: pinker@onet.eu > PostgreSQL version: 9.3.4 > Operating system: RedHat > Description: > > The problem is described here: > http://stackoverflow.com/questions/24382158/strange-cleanup-behaviour-with-for-update > > The main problem is that xmax values stays set with xid of transaction that > has already committed. The documentation says: "The identity (transaction > ID) of the deleting transaction, or zero for an undeleted row version. It is > possible for this column to be nonzero in a visible row version. That > usually indicates that the deleting transaction hasn't committed yet, or > that an attempted deletion was rolled back." This isn't a bug. It's expected that xmax sometimes is nonzero for undeleted rows. As you cite "It is possible for this column to be nonzero in a visible row version.". The list of cases in which that can happen isn't exhaustive... > I have used this feature for a queue to avoid locking, but it doesn't work > together with FOR UPDATE clause. I doubt you can sensibly use xmax for this unless you're willing to write server side C code. You're probably better of using something like pgq or advisory locks. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs