Skip to content

Commit ac0e2d3

Browse files
author
Amit Kapila
committed
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 ca7a0d1 commit ac0e2d3

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/backend/replication/logical/relation.c

+15-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ logicalrep_relmap_free_entry(LogicalRepRelMapEntry *entry)
144144
bms_free(remoterel->attkeys);
145145

146146
if (entry->attrmap)
147-
pfree(entry->attrmap);
147+
free_attrmap(entry->attrmap);
148148
}
149149

150150
/*
@@ -373,6 +373,13 @@ logicalrep_rel_open(LogicalRepRelId remoteid, LOCKMODE lockmode)
373373
int i;
374374
Bitmapset *missingatts;
375375

376+
/* Release the no-longer-useful attrmap, if any. */
377+
if (entry->attrmap)
378+
{
379+
free_attrmap(entry->attrmap);
380+
entry->attrmap = NULL;
381+
}
382+
376383
/* Try to find and lock the relation by name. */
377384
relid = RangeVarGetRelid(makeRangeVar(remoterel->nspname,
378385
remoterel->relname, -1),
@@ -620,6 +627,13 @@ logicalrep_partition_open(LogicalRepRelMapEntry *root,
620627
part_entry->partoid = partOid;
621628
}
622629

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+
623637
if (!entry->remoterel.remoteid)
624638
{
625639
int i;

0 commit comments

Comments
 (0)