From 9a7eeaf7b47ec6faff0bbc524412d46869136720 Mon Sep 17 00:00:00 2001 From: Dilip Kumar 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