Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2Ogt-0000Le-1X for pgsql-hackers@arkaria.postgresql.org; Thu, 21 Jan 2021 01:23:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l2Ogr-0003iD-UQ for pgsql-hackers@arkaria.postgresql.org; Thu, 21 Jan 2021 01:23:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2Ogr-0003i6-NQ for pgsql-hackers@lists.postgresql.org; Thu, 21 Jan 2021 01:23:13 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l2Ogp-0006yM-5h for pgsql-hackers@postgresql.org; Thu, 21 Jan 2021 01:23:13 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 10L1MvI7797827; Wed, 20 Jan 2021 20:22:57 -0500 From: Tom Lane To: Tomas Vondra cc: Amit Langote , "tsunakawa.takay@fujitsu.com" , "Andrey V. Lepikhov" , Tomas Vondra , "pgsql-hackers@postgresql.org" Subject: Re: POC: postgres_fdw insert batching In-reply-to: <261fbedb-1ced-82f7-e978-60cfe17bce07@enterprisedb.com> References: <20200628151002.7x5laxwpgvkyiu3q@development> <16fcfd4c-2d5e-67f7-fa69-9b5d119bac52@enterprisedb.com> <9d94c863-ce7c-ea7f-6b84-834c98929e2f@enterprisedb.com> <7e70a11e-cf5d-2e5f-a802-274c5e0e236b@enterprisedb.com> <261fbedb-1ced-82f7-e978-60cfe17bce07@enterprisedb.! com> Comments: In-reply-to Tomas Vondra message dated "Thu, 21 Jan 2021 01:21:29 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <797825.1611192177.1@sss.pgh.pa.us> Date: Wed, 20 Jan 2021 20:22:57 -0500 Message-ID: <797826.1611192177@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Tomas Vondra writes: > I may be wrong, but the most likely explanation seems to be this is due > to the junk filter initialization, which simply moves past the end of > the mtstate->resultRelInfo array. resultRelInfo is certainly pointing at garbage at that point. > It kinda seems the GetForeignModifyBatchSize call should happen before > that block. The attached patch fixes this for me (i.e. regression tests > pass with no valgrind reports. > Or did I get that wrong? Don't we need to initialize ri_BatchSize for *each* resultrelinfo, not merely the first one? That is, this new code needs to be somewhere inside a loop over the result rels. regards, tom lane