Re: POC: postgres_fdw insert batching - Mailing list pgsql-hackers

From Tomas Vondra
Subject Re: POC: postgres_fdw insert batching
Date
Msg-id 442cdcdc-5501-50f7-6efd-5df1668e11f9@enterprisedb.com
Whole thread Raw
In response to Re: POC: postgres_fdw insert batching  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers

On 1/21/21 2:22 AM, Tom Lane wrote:
> Tomas Vondra <tomas.vondra@enterprisedb.com> 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.
> 

Yup. It's pretty amazing the x86 machines seem to be mostly OK with it.

>> 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.
> 

Yeah, I think you're right. That's an embarrassing oversight :-(


regards

-- 
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Nikita Glukhov
Date:
Subject: Re: SQL/JSON: JSON_TABLE
Next
From: "Hou, Zhijie"
Date:
Subject: RE: Parallel INSERT (INTO ... SELECT ...)