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 1hCo6D-0006Vw-T5 for pgsql-bugs@arkaria.postgresql.org; Sat, 06 Apr 2019 16:23:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hCo6B-000326-HO for pgsql-bugs@arkaria.postgresql.org; Sat, 06 Apr 2019 16:23:19 +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 1hCo6B-00031z-5r for pgsql-bugs@lists.postgresql.org; Sat, 06 Apr 2019 16:23:19 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hCo68-0005Av-DT for pgsql-bugs@lists.postgresql.org; Sat, 06 Apr 2019 16:23:17 +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 x36GN6Fe019322; Sat, 6 Apr 2019 12:23:06 -0400 From: Tom Lane To: r.zharkov@postgrespro.ru cc: Amit Langote , Alvaro Herrera , Andres Freund , pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15727: PANIC: cannot abort transaction 295144144, it was already committed In-reply-to: <994bff111c549f45041cd1dc7473548e@postgrespro.ru> References: <20190403122027.GA17929@alvherre.pgsql> <994bff111c549f45041cd1dc7473548e@postgrespro.ru> Comments: In-reply-to r.zharkov@postgrespro.ru message dated "Wed, 03 Apr 2019 19:59:23 +0700" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <19216.1554567597.0@sss.pgh.pa.us> Date: Sat, 06 Apr 2019 12:23:06 -0400 Message-ID: <19321.1554567786@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <19216.1554567597.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable It seems that there may be some connection between this problem and EPQ. I was working on committing Amit's fix for bug #15677, which demonstrated that EPQ doesn't work for partitioned-table target rels. It seemed like there really needed to be regression test coverage for that, so I tried to convert his crasher example into an isolation test. It does indeed crash without Amit's fix ... but with it, lookee what I get: +error in steps c1 complexpartupdate: ERROR: unexpected table_lock_tuple = status: 1 That seems fully reproducible in this test. I haven't looked into exactly what's causing that, but now that we have a reproducible example, somebody should. I'm not quite sure if I should commit this as-is or wait till the other problem is fixed. A crash is probably worse than a bogus error, but I don't like committing obviously-wrong "expected" output. Thoughts? regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="bug-15677-fix-with-test.patch"; charset="us-ascii" Content-ID: <19216.1554567597.2@sss.pgh.pa.us> Content-Description: bug-15677-fix-with-test.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMa= in.c index 602a08e..5c4b3f4 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -2799,15 +2799,24 @@ EvalPlanQualStart(EPQState *epqstate, EState *pare= ntestate, Plan *planTree) estate->es_output_cid =3D parentestate->es_output_cid; if (parentestate->es_num_result_relations > 0) { - int numResultRelations =3D parentestate->es_num_result_relations; + int numResultRels =3D parentestate->es_num_result_relations; + int numRootResultRels =3D parentestate->es_num_root_result_relations; ResultRelInfo *resultRelInfos; = resultRelInfos =3D (ResultRelInfo *) - palloc(numResultRelations * sizeof(ResultRelInfo)); + palloc(numResultRels * sizeof(ResultRelInfo)); memcpy(resultRelInfos, parentestate->es_result_relations, - numResultRelations * sizeof(ResultRelInfo)); + numResultRels * sizeof(ResultRelInfo)); estate->es_result_relations =3D resultRelInfos; - estate->es_num_result_relations =3D numResultRelations; + estate->es_num_result_relations =3D numResultRels; + + /* Also transfer partitioned root result relations. */ + resultRelInfos =3D (ResultRelInfo *) + palloc(numRootResultRels * sizeof(ResultRelInfo)); + memcpy(resultRelInfos, parentestate->es_root_result_relations, + numRootResultRels * sizeof(ResultRelInfo)); + estate->es_root_result_relations =3D resultRelInfos; + estate->es_num_root_result_relations =3D numRootResultRels; } /* es_result_relation_info must NOT be copied */ /* es_trig_target_relations must NOT be copied */ diff --git a/src/test/isolation/expected/eval-plan-qual.out b/src/test/iso= lation/expected/eval-plan-qual.out index c09e97f..47843d7 100644 --- a/src/test/isolation/expected/eval-plan-qual.out +++ b/src/test/isolation/expected/eval-plan-qual.out @@ -562,3 +562,16 @@ step multireadwcte: <... completed> subid id = = 1 1 = + +starting permutation: simplepartupdate complexpartupdate c1 c2 +step simplepartupdate: = + update parttbl set a =3D a; + +step complexpartupdate: = + with u as (update parttbl set a =3D a returning parttbl.*) + update parttbl set a =3D u.a from u; + +step c1: COMMIT; +step complexpartupdate: <... completed> +error in steps c1 complexpartupdate: ERROR: unexpected table_lock_tuple = status: 1 +step c2: COMMIT; diff --git a/src/test/isolation/specs/eval-plan-qual.spec b/src/test/isola= tion/specs/eval-plan-qual.spec index 41c8d56..7d3f1f6 100644 --- a/src/test/isolation/specs/eval-plan-qual.spec +++ b/src/test/isolation/specs/eval-plan-qual.spec @@ -29,6 +29,10 @@ setup = CREATE TABLE jointest AS SELECT generate_series(1,10) AS id, 0 AS data; CREATE INDEX ON jointest(id); + + CREATE TABLE parttbl (a int) PARTITION BY LIST (a); + CREATE TABLE parttbl1 PARTITION OF parttbl FOR VALUES IN (1); + INSERT INTO parttbl VALUES (1); } = teardown @@ -37,6 +41,7 @@ teardown DROP TABLE accounts_ext; DROP TABLE p CASCADE; DROP TABLE table_a, table_b, jointest; + DROP TABLE parttbl; } = session "s1" @@ -133,6 +138,12 @@ step "selectresultforupdate" { where jt.id =3D y for update of jt, ss1, ss2; } = +# test for EPQ on a partitioned result table + +step "simplepartupdate" { + update parttbl set a =3D a; +} + = session "s2" setup { BEGIN ISOLATION LEVEL READ COMMITTED; } @@ -170,6 +181,10 @@ step "updateforcip3" { } step "wrtwcte" { UPDATE table_a SET value =3D 'tableAValue2' WHERE id =3D= 1; } step "wrjt" { UPDATE jointest SET data =3D 42 WHERE id =3D 7; } +step "complexpartupdate" { + with u as (update parttbl set a =3D a returning parttbl.*) + update parttbl set a =3D u.a from u; +} step "c2" { COMMIT; } step "r2" { ROLLBACK; } = @@ -234,3 +249,5 @@ permutation "wrtwcte" "readwcte" "c1" "c2" permutation "wrjt" "selectjoinforupdate" "c2" "c1" permutation "wrjt" "selectresultforupdate" "c2" "c1" permutation "wrtwcte" "multireadwcte" "c1" "c2" + +permutation "simplepartupdate" "complexpartupdate" "c1" "c2" ------- =_aaaaaaaaaa0--