v2-PG15-0001-Drop-the-tuple-slot-when-no-longer-needed.patch
application/octet-stream
Filename: v2-PG15-0001-Drop-the-tuple-slot-when-no-longer-needed.patch
Type: application/octet-stream
Part: 0
Patch
Format: format-patch
Series: patch v2-0001
Subject: Drop the tuple slot when no longer needed
| File | + | − |
|---|---|---|
| src/backend/replication/pgoutput/pgoutput.c | 13 | 0 |
From 354bd884059d8a7b0da1c194482ab84cfd5fd9f9 Mon Sep 17 00:00:00 2001
From: Hou Zhijie <houzj.fnst@cn.fujitsu.com>
Date: Thu, 27 Jun 2024 10:57:34 +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 5fc0defec3..6bd8e95356 100644
--- a/src/backend/replication/pgoutput/pgoutput.c
+++ b/src/backend/replication/pgoutput/pgoutput.c
@@ -1587,6 +1587,19 @@ pgoutput_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
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);
+ }
+
/* Cleanup */
MemoryContextSwitchTo(old);
MemoryContextReset(data->context);
--
2.30.0.windows.2