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 1h3vmQ-0007If-AE for pgsql-bugs@arkaria.postgresql.org; Wed, 13 Mar 2019 04:46:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h3vmO-00072L-PM for pgsql-bugs@arkaria.postgresql.org; Wed, 13 Mar 2019 04:46:12 +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 1h3vmO-00072E-FW for pgsql-bugs@lists.postgresql.org; Wed, 13 Mar 2019 04:46:12 +0000 Received: from tama50.ecl.ntt.co.jp ([129.60.39.147]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h3vmK-0005Rl-Bp for pgsql-bugs@lists.postgresql.org; Wed, 13 Mar 2019 04:46:10 +0000 Received: from vc2.ecl.ntt.co.jp (vc2.ecl.ntt.co.jp [129.60.86.154]) by tama50.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id x2D4k5Pp005732; Wed, 13 Mar 2019 13:46:05 +0900 Received: from vc2.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id 2D9B36384B7; Wed, 13 Mar 2019 13:46:05 +0900 (JST) Received: from jcms-pop21.ecl.ntt.co.jp (jcms-pop21.ecl.ntt.co.jp [129.60.87.134]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id 224A3638493; Wed, 13 Mar 2019 13:46:05 +0900 (JST) Received: from [127.0.0.1] (unknown [129.60.241.61]) by jcms-pop21.ecl.ntt.co.jp (Postfix) with ESMTPSA id 1B816400794; Wed, 13 Mar 2019 13:46:05 +0900 (JST) Subject: Re: BUG #15677: Crash while deleting from partitioned table From: Amit Langote References: <15677-0bf089579b4cd02d@postgresql.org> <3ad5ba71-d200-96da-f903-7e3b16416140@lab.ntt.co.jp> <20190311045521.GF1818@paquier.xyz> <27a7a849-c576-35f6-eb1e-5ff858841f65@lab.ntt.co.jp> Message-ID: Date: Wed, 13 Mar 2019 13:45:51 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.3 MIME-Version: 1.0 In-Reply-To: <27a7a849-c576-35f6-eb1e-5ff858841f65@lab.ntt.co.jp> Content-Type: multipart/mixed; boundary="------------36917E21ED5671ECAAFBCB05" Content-Language: en-US X-CC-Mail-RelayStamp: 1 To: Michael Paquier Cc: infernorb@gmail.com, pgsql-bugs@lists.postgresql.org, PG Bug reporting form X-TM-AS-MML: disable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------36917E21ED5671ECAAFBCB05 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 2019/03/11 14:04, Amit Langote wrote: > On 2019/03/11 13:55, Michael Paquier wrote: >> On Mon, Mar 11, 2019 at 12:55:05PM +0900, Amit Langote wrote: >>> Forgot to mention that this bug exists in PG 10, 11, and HEAD. The same >>> patch applies to all three branches. >> >> Could you add that to the future CF so as we don't forget? > > Done: > > * update/delete on partitioned tables may crash under concurrency * > https://commitfest.postgresql.org/23/2057/ Thanks to cfbot [1], I came to know about a silly typo I had made in the patch. Attached updated patch. Thanks, Amit [1] https://travis-ci.org/postgresql-cfbot/postgresql/builds/505157218 --------------36917E21ED5671ECAAFBCB05 Content-Type: text/plain; charset=UTF-8; name="EvalPlanQualStart-bug-v2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="EvalPlanQualStart-bug-v2.patch" diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 499917d45f..7740306aca 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -3059,15 +3059,24 @@ EvalPlanQualStart(EPQState *epqstate, EState *parentestate, Plan *planTree) estate->es_output_cid = parentestate->es_output_cid; if (parentestate->es_num_result_relations > 0) { - int numResultRelations = parentestate->es_num_result_relations; + int numResultRels = parentestate->es_num_result_relations; + int numRootResultRels = parentestate->es_num_root_result_relations; ResultRelInfo *resultRelInfos; resultRelInfos = (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 = resultRelInfos; - estate->es_num_result_relations = numResultRelations; + estate->es_num_result_relations = numResultRels; + + /* Also transfer partitioned root result relations. */ + resultRelInfos = (ResultRelInfo *) + palloc(numRootResultRels * sizeof(ResultRelInfo)); + memcpy(resultRelInfos, parentestate->es_root_result_relations, + numRootResultRels * sizeof(ResultRelInfo)); + estate->es_root_result_relations = resultRelInfos; + estate->es_num_root_result_relations = numRootResultRels; } /* es_result_relation_info must NOT be copied */ /* es_trig_target_relations must NOT be copied */ --------------36917E21ED5671ECAAFBCB05--