This is an automated email from the ASF dual-hosted git repository.

reshke pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git

commit 57bdb1be1713c023c954aa004205c594d4304c1a
Author: Amit Kapila <[email protected]>
AuthorDate: Thu Jun 23 09:20:41 2022 +0530

    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 e1551f96e6) 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/oszpr01mb6310f46cd425a967e4aef736fd...@oszpr01mb6310.jpnprd01.prod.outlook.com
---
 src/backend/replication/logical/relation.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/backend/replication/logical/relation.c 
b/src/backend/replication/logical/relation.c
index d0ed64da17d..bd303546cce 100644
--- a/src/backend/replication/logical/relation.c
+++ b/src/backend/replication/logical/relation.c
@@ -376,7 +376,7 @@ logicalrep_rel_open(LogicalRepRelId remoteid, LOCKMODE 
lockmode)
                /* Release the no-longer-useful attrmap, if any. */
                if (entry->attrmap)
                {
-                       pfree(entry->attrmap);
+                       free_attrmap(entry->attrmap);
                        entry->attrmap = NULL;
                }
 
@@ -627,6 +627,13 @@ logicalrep_partition_open(LogicalRepRelMapEntry *root,
                part_entry->partoid = partOid;
        }
 
+       /* Release the no-longer-useful attrmap, if any. */
+       if (entry->attrmap)
+       {
+               free_attrmap(entry->attrmap);
+               entry->attrmap = NULL;
+       }
+
        if (!entry->remoterel.remoteid)
        {
                int                     i;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to