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 1hksCK-0004DK-AJ for pgsql-bugs@arkaria.postgresql.org; Tue, 09 Jul 2019 15:38:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hksCI-0007f6-Ox for pgsql-bugs@arkaria.postgresql.org; Tue, 09 Jul 2019 15:38:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hksCI-0007d0-Gg for pgsql-bugs@lists.postgresql.org; Tue, 09 Jul 2019 15:38:26 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hksCF-0008KX-Tn for pgsql-bugs@lists.postgresql.org; Tue, 09 Jul 2019 15:38:26 +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 x69FcDRh024531; Tue, 9 Jul 2019 11:38:13 -0400 From: Tom Lane To: Thomas Munro cc: Alex Aktsipetrov , PostgreSQL mailing lists , Andres Freund Subject: Re: BUG #15900: `executor could not find named tuplestore` in triggers with transition table and row locks In-reply-to: References: <15900-bc482754fe8d7415@postgresql.org> Comments: In-reply-to Thomas Munro message dated "Tue, 09 Jul 2019 23:47:28 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <24529.1562686693.1@sss.pgh.pa.us> Date: Tue, 09 Jul 2019 11:38:13 -0400 Message-ID: <24530.1562686693@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thomas Munro writes: > On Tue, Jul 9, 2019 at 1:13 PM Thomas Munro wrote: >> I think it's highly likely that bug #15720 was a case of this bug and >> would be fixed by this patch. Agreed. I think your version of the fix is good, and you should mention #15720 too in the commit message. >> Alex's repro doesn't work on 11 though, >> because EPQ is not entered at all. Which raises the question: why do >> we need to enter EPQ after commit ad0bda5d on 12/master, for a row >> that hasn't been updated by anyone else? > Explanation: since ad0bda5d24ea, ExecLockRows() always calls > EvalPlanQualBegin() which initialises the plan state, and in this case > ExecInitNamedTuplestoreScan() errors out due to the bug. Before, you > needed the right concurrency scenario (epq_needed) before we did that, > as the reporter of bug #15720 discovered. I'm quite desperately unhappy about this observation, because EvalPlanQualBegin is a *large* amount of overhead that is usually unnecessary, and is now going to be paid for *every locked row* whether there's any conflict on it or not. I do not find that acceptable. Why is it necessary to do this before finding that there's an update conflict? regards, tom lane