Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Drop the temporary tuple slots allocated by pgoutput.
authorAmit Kapila <akapila@postgresql.org>
Thu, 27 Jun 2024 05:13:52 +0000 (10:43 +0530)
committerAmit Kapila <akapila@postgresql.org>
Thu, 27 Jun 2024 05:13:52 +0000 (10:43 +0530)
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 temporary slots, leading to
resource leakage.

Reported-by: Bowen Shi
Author: Hou Zhijie
Reviewed-by: Amit Kapila
Backpatch-through: 15
Discussion: https://postgr.es/m/CAM_vCudv8dc3sjWiPkXx5F2b27UV7_YRKRbtSCcE-pv=cVACGA@mail.gmail.com

src/backend/replication/pgoutput/pgoutput.c

index 5fc0defec3a0503a2f483c504bb07a4228afc8d1..abb82ecb18d400617eda8d66d5e649a8d1a91f92 100644 (file)
@@ -1587,6 +1587,16 @@ pgoutput_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
        ancestor = NULL;
    }
 
+   /* Drop the new slots that were used to store the converted tuples. */
+   if (relentry->attrmap)
+   {
+       if (old_slot)
+           ExecDropSingleTupleTableSlot(old_slot);
+
+       if (new_slot)
+           ExecDropSingleTupleTableSlot(new_slot);
+   }
+
    /* Cleanup */
    MemoryContextSwitchTo(old);
    MemoryContextReset(data->context);