Skip to content

Commit 57bdb1b

Browse files
Amit Kapilareshke
authored andcommitted
Fix memory leak due to LogicalRepRelMapEntry.attrmap.
When rebuilding the relation mapping on subscribers, we were not releasing the attribute mapping's memory which was no longer required. The attribute mapping used in logical tuple conversion was refactored in PG13 (by commit e1551f9) but we forgot to update the related code that frees the attribute map. Author: Hou Zhijie Reviewed-by: Amit Langote, Amit Kapila, Shi yu Backpatch-through: 10, where it was introduced Discussion: https://postgr.es/m/OSZPR01MB6310F46CD425A967E4AEF736FDA49@OSZPR01MB6310.jpnprd01.prod.outlook.com
1 parent c057948 commit 57bdb1b

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/backend/replication/logical/relation.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ logicalrep_rel_open(LogicalRepRelId remoteid, LOCKMODE lockmode)
376376
/* Release the no-longer-useful attrmap, if any. */
377377
if (entry->attrmap)
378378
{
379-
pfree(entry->attrmap);
379+
free_attrmap(entry->attrmap);
380380
entry->attrmap = NULL;
381381
}
382382

@@ -627,6 +627,13 @@ logicalrep_partition_open(LogicalRepRelMapEntry *root,
627627
part_entry->partoid = partOid;
628628
}
629629

630+
/* Release the no-longer-useful attrmap, if any. */
631+
if (entry->attrmap)
632+
{
633+
free_attrmap(entry->attrmap);
634+
entry->attrmap = NULL;
635+
}
636+
630637
if (!entry->remoterel.remoteid)
631638
{
632639
int i;

0 commit comments

Comments
 (0)