On Mon, May 31, 2021 at 8:50 AM Dilip Kumar <dilipbal...@gmail.com> wrote:
>
> On Mon, 31 May 2021 at 8:21 AM, Amit Kapila <amit.kapil...@gmail.com> wrote:
>>
>> Okay, I think it would be better if we can test this once for the
>> streaming case as well. Dilip, would you like to do that and send the
>> updated patch as per one of the comments by Tomas?
>
>
> I will do that sometime.


I have changed patches as Tomas suggested and also created back patches.

-- 
Regards,
Dilip Kumar
EnterpriseDB: http://www.enterprisedb.com
From 792892fce8771c003eca16847e5e494a70f318ed Mon Sep 17 00:00:00 2001
From: Dilip Kumar <dilipkumar@localhost.localdomain>
Date: Mon, 31 May 2021 15:20:05 +0530
Subject: [PATCH v1] Fix memory leak in toast hash

While cleaning up the changes just destory the toast hash so that if
it is not already done in some cases we don't leak memory.
---
 src/backend/replication/logical/reorderbuffer.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 5251932..89fa7e7 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -391,6 +391,9 @@ ReorderBufferReturnTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
 		txn->tuplecid_hash = NULL;
 	}
 
+	/* cleanup the toast hash */
+	ReorderBufferToastReset(rb, txn);
+
 	if (txn->invalidations)
 	{
 		pfree(txn->invalidations);
-- 
1.8.3.1

From 9a7eeaf7b47ec6faff0bbc524412d46869136720 Mon Sep 17 00:00:00 2001
From: Dilip Kumar <dilipkumar@localhost.localdomain>
Date: Thu, 27 May 2021 10:03:27 +0530
Subject: [PATCH v1] Fix memory leak in toast hash

While cleaning up the changes just destory the toast hash so that if
it is not already done in some cases we don't leak memory.
---
 src/backend/replication/logical/reorderbuffer.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c
index 2d9e127..ab65d3b 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -437,6 +437,9 @@ ReorderBufferReturnTXN(ReorderBuffer *rb, ReorderBufferTXN *txn)
 		txn->tuplecid_hash = NULL;
 	}
 
+	/* cleanup the toast hash */
+	ReorderBufferToastReset(rb, txn);
+
 	if (txn->invalidations)
 	{
 		pfree(txn->invalidations);
@@ -1637,6 +1640,9 @@ ReorderBufferTruncateTXN(ReorderBuffer *rb, ReorderBufferTXN *txn, bool txn_prep
 		txn->tuplecid_hash = NULL;
 	}
 
+	/* Cleanup the toast hash. */
+	ReorderBufferToastReset(rb, txn);
+
 	/* If this txn is serialized then clean the disk space. */
 	if (rbtxn_is_serialized(txn))
 	{
-- 
1.8.3.1

Reply via email to