Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iGc0E-0004Uv-O9 for pgsql-bugs@arkaria.postgresql.org; Sat, 05 Oct 2019 04:49:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iGc0D-00018S-KO for pgsql-bugs@arkaria.postgresql.org; Sat, 05 Oct 2019 04:49:09 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iGbxB-0007X7-D0 for pgsql-bugs@lists.postgresql.org; Sat, 05 Oct 2019 04:46:03 +0000 Received: from wout3-smtp.messagingengine.com ([64.147.123.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iGbwq-0001mL-Hb for pgsql-bugs@lists.postgresql.org; Sat, 05 Oct 2019 04:46:00 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 83D983AE; Sat, 5 Oct 2019 00:45:38 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sat, 05 Oct 2019 00:45:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=yzYi2KjKlxNP4tKiXBiAFrVYFms bxWIEzcVWFWSzxG8=; b=Pb35/R1AO2p+pEH9VmHzAf/C+E37xcGBgDPo5TIwFS0 bXlLRpNEJNWg6vP3yRfPxmVVsHfqhS2pNOBLk7blO0i1eNSG5dGg7l1xqotn0K+o AY5t3dc95xIBKea4+rn5HAj3Kibp9/SfopkaYeL/yNs+6t+dIoUemEXszvrtqGWB gUSP4FaKFYWBDoDI7kR531p2IZGzhVyU8Ceb5u6tlBX080B9i1u6j/gXH2nxWFEq bT8whSxi9gVICScJ5ZoPz84EIbrx21SPNbX7l0K59GxXL/rq8+XLG572WWgXt0LN fnBoMPTlIlNBaD4IgnyNGhVtri6fmzQGvJosI7jb0Zw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=yzYi2K jKlxNP4tKiXBiAFrVYFmsbxWIEzcVWFWSzxG8=; b=YXVfJF+6i2m43Kew6FTmOM 7L+uEBaPp/k9J3iswN8tms8xcnnC+x9pCr1FtEceZuoueKywUkzLpKsCN8j0BOon ldGxQGDPzEU57+dgAZ1z0+bfEQzYhHdq7rk41xgjZVWPjM24oVhejxVMKj1/xMHr pJY801EQ3oh2+vYjB03Su/qt5o6wAtyN3mTgiNTxnd7NDtPWAYIPjqzZWsFVQJFY h65mvvOCfyrNVuchXXej7+1DRmz6Asv/tKDC8k9jmzNJ3Ee9YuXSJ3QendETTCWB jyIXmJ1Q87ZiHwIQmVoPmJiJLFawf78TsDHzI/Hvf7PkHAgPsbXmW9i6WTgiRRWA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrhedvgdekkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuffhomhgrih hnpehpohhsthhgrhgvshhqlhdrohhrghenucfkphepieejrddukedtrdeivddrudejtden ucfrrghrrghmpehmrghilhhfrhhomheprghnughrvghssegrnhgrrhgriigvlhdruggvne cuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Received: from intern.anarazel.de (c-67-180-62-170.hsd1.ca.comcast.net [67.180.62.170]) by mail.messagingengine.com (Postfix) with ESMTPA id 2E18F8005C; Sat, 5 Oct 2019 00:45:37 -0400 (EDT) Date: Fri, 4 Oct 2019 21:45:35 -0700 From: Andres Freund To: Peter Geoghegan Cc: Tom Lane , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16036: Segmentation fault while doing an update Message-ID: <20191005044535.onxnohvdhp5ihmd3@alap3.anarazel.de> References: <4E1FB33C-7280-487B-B3D1-D3C247AA9E3D@anarazel.de> <746398E3-F4E1-4F14-A686-3394F27011DC@gmail.com> <20191004032020.se46diwqas43e3tw@alap3.anarazel.de> <11540.1570159561@sss.pgh.pa.us> <20191004043021.ylfbxcjqyypphfft@alap3.anarazel.de> <20191004192848.s3cgkt7n7g3cbvja@alap3.anarazel.de> <20191004214300.pqe7fruaemklz5qn@alap3.anarazel.de> <20191004222437.45qmglpto43pd3jb@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191004222437.45qmglpto43pd3jb@alap3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2019-10-04 15:24:37 -0700, Andres Freund wrote: > On 2019-10-04 14:43:00 -0700, Andres Freund wrote: > > > I think there's a good case to be made to backpatch the tests further > > > than 12, but I'm not sure about it? They do pass (with one error message > > > about a failure to delete changed to a failure to update, we didn't use > > > to be able to discern) back to 9.6, requiring > > > > I did push the tests back to 9.6. > > There's a few ordering violations in the tests, e.g.: > > https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=crake&dt=2019-10-04%2021%3A51%3A13 I've now disabled that portion of the test. It look to me like this might be a subtle upsert bug. What happens is that in the isolationtester sequence (all operating on one row, and all already in a transaction): "s1_upd_a_data" "s3_upd_a_data" "s2_upsert_a_data" "s1_upd_a_data" "s1_c" "s3_del_a" "s3_c" "s2_c" sometimes the s2_upsert_a_data gets to update the row before the s3_upd_a_data. That does *not* happen with a plain update, even though there's at that point always a target row to operate on (i.e. this happens before s3_del_a is reached). I think the cause for that might be that the check_exclusion_or_unique_constraint() check done for upsert (via ExecCheckIndexConstraints() in ExecInsert()) does a XactLockTableWait() without, like heapam.c would, ordering via a tuple lock. Since it's clearly not 12 specific, and not really related to triggers / EPQ, I think disabling it for now is a sensible choice. > key-a val-a-s1-ups1-ups1 > step s1_c: COMMIT; > -s3: NOTICE: upd: text key-a = text key-a: t > -s3: NOTICE: upk: text val-a-s1-ups1-ups1 <> text mismatch: t > -s3: NOTICE: trigger: name rep_b_u; when: BEFORE; lev: ROWs; op: UPDATE; old: (key-a,val-a-s1-ups1-ups1) new: (key-a,val-a-s1-ups1-ups1-ups3) > -s3: NOTICE: trigger: name rep_a_u; when: AFTER; lev: ROWs; op: UPDATE; old: (key-a,val-a-s1-ups1-ups1) new: (key-a,val-a-s1-ups1-ups1-ups3) > -step s3_upd_a_data: <... completed> > +s2: NOTICE: upd: text key-a = text key-a: t > +s2: NOTICE: upk: text val-a-s1-ups1-ups1 <> text mismatch: t > +s2: NOTICE: trigger: name rep_b_u; when: BEFORE; lev: ROWs; op: UPDATE; old: (key-a,val-a-s1-ups1-ups1) new: (key-a,val-a-s1-ups1-ups1-upserts2) > +s2: NOTICE: trigger: name rep_a_u; when: AFTER; lev: ROWs; op: UPDATE; old: (key-a,val-a-s1-ups1-ups1) new: (key-a,val-a-s1-ups1-ups1-upserts2) > +step s2_upsert_a_data: <... completed> > key data > > I was under the assumption that it'd be deterministic who gets to > continue with a speculative insertion, but that ain't so. This was a preliminary theory, a wrong one: Speculative insertions aren't actually involved, see above... Greetings, Andres Freund