Issue in ExecCleanupTupleRouting()

From: Etsuro Fujita <fujita(dot)etsuro(at)lab(dot)ntt(dot)co(dot)jp>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, "'Amit Langote'" <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>, David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
Subject: Issue in ExecCleanupTupleRouting()
Date: 2019-04-11 13:05:19
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


(added Alvaro, Amit, and David)

While working on an update-tuple-routing bug in postgres_fdw [1], I
noticed this change to ExecCleanupTupleRouting() made by commit

+ /*
+ * Check if this result rel is one belonging to the node's subplans,
+ * if so, let ExecEndPlan() clean it up.
+ */
+ if (htab)
+ {
+ Oid partoid;
+ bool found;
+ partoid = RelationGetRelid(resultRelInfo->ri_RelationDesc);
+ (void) hash_search(htab, &partoid, HASH_FIND, &found);
+ if (found)
+ continue;
+ }

/* Allow any FDWs to shut down if they've been exercised */
- if (resultRelInfo->ri_PartitionReadyForRouting &&
- resultRelInfo->ri_FdwRoutine != NULL &&
+ if (resultRelInfo->ri_FdwRoutine != NULL &&
resultRelInfo->ri_FdwRoutine->EndForeignInsert != NULL)


This skips subplan resultrels before calling EndForeignInsert() if they
are foreign tables, which I think causes an issue: the FDWs would fail
to release resources for their foreign insert operations, because
ExecEndPlan() and ExecEndModifyTable() don't do anything to allow them
to do that. So I think we should skip subplan resultrels after
EndForeignInsert(). Attached is a small patch for that.

Best regards,
Etsuro Fujita


Attachment Content-Type Size
ExecCleanupTupleRouting.patch text/x-patch 1.1 KB


Browse pgsql-hackers by date

  From Date Subject
Next Message Rafia Sabih 2019-04-11 13:05:34 Re: Zedstore - compressed in-core columnar storage
Previous Message Ibrar Ahmed 2019-04-11 12:43:09 Re: pgbench - add minimal stats on initialization