Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3a6ef0c

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 9adc4cd commit 3a6ef0c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/backend/replication/logical/relation.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ logicalrep_relmap_free_entry(LogicalRepRelMapEntry *entry)
145145
bms_free(remoterel->attkeys);
146146

147147
if (entry->attrmap)
148-
pfree(entry->attrmap);
148+
free_attrmap(entry->attrmap);
149149
}
150150

151151
/*
@@ -337,6 +337,13 @@ logicalrep_rel_open(LogicalRepRelId remoteid, LOCKMODE lockmode)
337337
MemoryContext oldctx;
338338
int i;
339339

340+
/* Release the no-longer-useful attrmap, if any. */
341+
if (entry->attrmap)
342+
{
343+
free_attrmap(entry->attrmap);
344+
entry->attrmap = NULL;
345+
}
346+
340347
/* Try to find and lock the relation by name. */
341348
relid = RangeVarGetRelid(makeRangeVar(remoterel->nspname,
342349
remoterel->relname, -1),
@@ -588,6 +595,13 @@ logicalrep_partition_open(LogicalRepRelMapEntry *root,
588595
part_entry->partoid = partOid;
589596
}
590597

598+
/* Release the no-longer-useful attrmap, if any. */
599+
if (entry->attrmap)
600+
{
601+
free_attrmap(entry->attrmap);
602+
entry->attrmap = NULL;
603+
}
604+
591605
if (!entry->remoterel.remoteid)
592606
{
593607
int i;

0 commit comments

Comments
 (0)