v1-0001-Fix-memory-leak-in-toast-hash_v13-to-v9.6.patch

text/x-patch

Filename: v1-0001-Fix-memory-leak-in-toast-hash_v13-to-v9.6.patch
Type: text/x-patch
Part: 0
Message: Re: Decoding speculative insert with toast leaks memory

Patch

Format: format-patch
Series: patch v1-0001
Subject: Fix memory leak in toast hash
File+
src/backend/replication/logical/reorderbuffer.c 3 0
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