From: | Zhihong Yu <zyu(at)yugabyte(dot)com> |
---|---|
To: | Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com> |
Cc: | Amit Langote <amitlangote09(at)gmail(dot)com>, "tsunakawa(dot)takay(at)fujitsu(dot)com" <tsunakawa(dot)takay(at)fujitsu(dot)com>, "Andrey V(dot) Lepikhov" <a(dot)lepikhov(at)postgrespro(dot)ru>, Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: POC: postgres_fdw insert batching |
Date: | 2021-01-21 00:17:39 |
Message-ID: | CALNJ-vSt7Fn=oj4NxAyCDQQF-1yxmP=LYyQwciApg4L+QdYJQw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
The assignment to resultRelInfo is done when junk_filter_needed is true:
if (junk_filter_needed)
{
resultRelInfo = mtstate->resultRelInfo;
Should the code for determining batch size access mtstate->resultRelInfo
directly ?
diff --git a/src/backend/executor/nodeModifyTable.c
b/src/backend/executor/nodeModifyTable.c
index 9c36860704..a6a814454d 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -2798,17 +2798,17 @@ ExecInitModifyTable(ModifyTable *node, EState
*estate, int eflags)
* size (a FDW may support batching, but it may be disabled for the
* server/table).
*/
- if (!resultRelInfo->ri_usesFdwDirectModify &&
+ if (!mtstate->resultRelInfo->ri_usesFdwDirectModify &&
operation == CMD_INSERT &&
- resultRelInfo->ri_FdwRoutine != NULL &&
- resultRelInfo->ri_FdwRoutine->GetForeignModifyBatchSize &&
- resultRelInfo->ri_FdwRoutine->ExecForeignBatchInsert)
- resultRelInfo->ri_BatchSize =
-
resultRelInfo->ri_FdwRoutine->GetForeignModifyBatchSize(resultRelInfo);
+ mtstate->resultRelInfo->ri_FdwRoutine != NULL &&
+ mtstate->resultRelInfo->ri_FdwRoutine->GetForeignModifyBatchSize &&
+ mtstate->resultRelInfo->ri_FdwRoutine->ExecForeignBatchInsert)
+ mtstate->resultRelInfo->ri_BatchSize =
+
mtstate->resultRelInfo->ri_FdwRoutine->GetForeignModifyBatchSize(mtstate->resultRelInfo);
else
- resultRelInfo->ri_BatchSize = 1;
+ mtstate->resultRelInfo->ri_BatchSize = 1;
- Assert(resultRelInfo->ri_BatchSize >= 1);
+ Assert(mtstate->resultRelInfo->ri_BatchSize >= 1);
/*
* Lastly, if this is not the primary (canSetTag) ModifyTable node,
add it
Cheers
On Wed, Jan 20, 2021 at 3:52 PM Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
wrote:
> Hmm, seems that florican doesn't like this :-(
>
>
> https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=florican&dt=2021-01-20%2023%3A08%3A15
>
> It's a i386 machine running FreeBSD, so not sure what exactly it's picky
> about. But when I tried running this under valgrind, I get some strange
> failures in the new chunk in ExecInitModifyTable:
>
> /*
> * Determine if the FDW supports batch insert and determine the batch
> * size (a FDW may support batching, but it may be disabled for the
> * server/table).
> */
> if (!resultRelInfo->ri_usesFdwDirectModify &&
> operation == CMD_INSERT &&
> resultRelInfo->ri_FdwRoutine != NULL &&
> resultRelInfo->ri_FdwRoutine->GetForeignModifyBatchSize &&
> resultRelInfo->ri_FdwRoutine->ExecForeignBatchInsert)
> resultRelInfo->ri_BatchSize =
>
> resultRelInfo->ri_FdwRoutine->GetForeignModifyBatchSize(resultRelInfo);
> else
> resultRelInfo->ri_BatchSize = 1;
>
> Assert(resultRelInfo->ri_BatchSize >= 1);
>
> It seems as if the resultRelInfo is not initialized, or something like
> that. I wouldn't be surprised if the 32-bit machine was pickier and
> failing because of that.
>
> A sample of the valgrind log is attached. It's pretty much just
> repetitions of these three reports.
>
> regards
>
> --
> Tomas Vondra
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
From | Date | Subject | |
---|---|---|---|
Next Message | Tomas Vondra | 2021-01-21 00:21:29 | Re: POC: postgres_fdw insert batching |
Previous Message | David Rowley | 2021-01-21 00:16:55 | Heap's backwards scan scans the incorrect pages with heap_setscanlimits() |