Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKwK8-0003LY-0L for pgsql-bugs@arkaria.postgresql.org; Wed, 06 Jul 2016 23:33:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bKwK7-00068y-Fc for pgsql-bugs@arkaria.postgresql.org; Wed, 06 Jul 2016 23:33:43 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bKwK6-00068r-Ub for pgsql-bugs@postgresql.org; Wed, 06 Jul 2016 23:33:43 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bKwK3-0001LG-Lg for pgsql-bugs@postgresql.org; Wed, 06 Jul 2016 23:33:41 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 2C556203CC; Wed, 6 Jul 2016 19:33:38 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Wed, 06 Jul 2016 19:33:38 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=mSzsesqk3JrAj9an5J3lVjuGBX0=; b=l/Nqt P4L04NDTM9Lj3BcedzrAdiX6w7Y8a/cmPK71R3gyl7TjAs+aMChZEyHhddxrn4UU oRzU80bJX4bI8GTbTFI4IdS6HknOCCxg0kjzq7TN42JogpiSqe9uc/N+dLYQ6lqg PHxTXHRXBFclxRi27iNUZWpR2czxKp2NFNFuhg= X-Sasl-enc: ALdU5Ng2/d5j1flld9/chvD7BsgCisAwE9m9LfY9DMms 1467848017 Received: from intern.anarazel.de (somacentral1.static.monkeybrains.net [162.217.75.74]) by mail.messagingengine.com (Postfix) with ESMTPA id C7897CCD84; Wed, 6 Jul 2016 19:33:37 -0400 (EDT) Date: Wed, 6 Jul 2016 16:33:36 -0700 From: Andres Freund To: Peter Geoghegan Cc: Oskari Saarenmaa , Michael Paquier , Peter Tripp , Virendra Negi , pgsql-bugs Subject: Re: BUG #14150: Attempted to delete invisible tuple Message-ID: <20160706233336.irsrxqct3lc5vcwp@alap3.anarazel.de> References: <20160519123338.12513.20271@wrigleys.postgresql.org> <88248a24-47d1-d575-a63f-2b56a09f82e2@aiven.io> <62f3793f-13d6-567c-e512-f29d1fd76d00@aiven.io> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 2016-07-06 16:07:38 -0700, Peter Geoghegan wrote: > On Wed, Jul 6, 2016 at 3:30 AM, Oskari Saarenmaa wrote: > >> ISTM this is caused by toast knowing nothing about speculative > >> insertion: when two backends have executed a speculative heap_insert > >> with a conflicting key and the latter one tries to abort after receiving > >> specConflict there's nothing in tqual.c to say that the toast rows > >> associated with speculative insertion should be visible to that operation. > > > > > > The attached patch against current master allows heap_abort_speculative to > > delete toast rows created by the same command which makes the above test > > case and "make check" run without failures. Note that I haven't touched > > this code before so I don't know how safe my patch is. > > I don't really understand your explanation of what this patch does. > Obviously heap_abort_speculative() often has no apparent problem with > any of this; this bug involves a relatively rare race condition > scenario where there *is* a problem. Did you see oskari's reproducer in http://archives.postgresql.org/message-id/88248a24-47d1-d575-a63f-2b56a09f82e2%40aiven.io ? It's not really particularly hard to reproduce with that (pretty basic interaction). Works like in 80% of the cases I tried, within less than a sec. > We didn't simply neglect to make heap_abort_speculative() consider > TOAST at all, though. Well, not quite, but nearly. Afaics it currently can only work if the toasted columns have been inserted by a different command, before the INSERT ON CONFLICT does anything. I don't see how it can work for newly inserted toast data. When heap_abort_speculative deletes toast data, when would it *ever* not fail if the same command executed the toast data? Andres -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs