From a69b61303ed9d3897e938070ce6b974d5d9b3e95 Mon Sep 17 00:00:00 2001 From: Hou Zhijie Date: Tue, 25 Jun 2024 19:30:07 +0800 Subject: [PATCH v2] Drop the tuple slot when no longer needed In pgoutput, when converting the child table's tuple format to match the parent table's, we temporarily create a new slot to store the converted tuple. However, we missed to drop such temp slots, leading to resource accumulation and causing the walsender to hang. This commit fix the issue by dropping the temp slots in each cycle. --- src/backend/replication/pgoutput/pgoutput.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c index d2b35cfb96..490e0af014 100644 --- a/src/backend/replication/pgoutput/pgoutput.c +++ b/src/backend/replication/pgoutput/pgoutput.c @@ -1554,6 +1554,19 @@ cleanup: ancestor = NULL; } + /* + * If the tuple was converted, drop the new slot that was used to store + * the converted tuple. + */ + if (relentry->attrmap) + { + if (old_slot) + ExecDropSingleTupleTableSlot(old_slot); + + if (new_slot) + ExecDropSingleTupleTableSlot(new_slot); + } + MemoryContextSwitchTo(old); MemoryContextReset(data->context); } -- 2.30.0.windows.2