Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8364354

Browse files
committed
Fix memory leak in pgoutput with relation attribute map
pgoutput caches the attribute map of a relation, that is free()'d onlywhen validating a RelationSyncEntry. However, this code path is nottaken when calling any of the SQL functions able to do some logicaldecoding, like pg_logical_slot_{get,peek}_changes(), leaking some memoryinto CacheMemoryContext on repeated calls.To address this, a relation's attribute map is allocated inPGOutputData's cachectx, free()'d at the end of the execution of theseSQL functions when logical decoding ends. This is available down to 15.v13 and v14 have a similar leak, which will be dealt with later.Reported-by: Masahiko SawadaAuthor: Vignesh CReviewed-by: Hou ZhijieDiscussion:https://postgr.es/m/CAD21AoDkAhQVSukOfH3_reuF-j4EU0-HxMqU3dU+bSTxsqT14Q@mail.gmail.comDiscussion:https://postgr.es/m/CALDaNm1hewNAsZ_e6FF52a=9drmkRJxtEPrzCB6-9mkJyeBBqA@mail.gmail.comBackpatch-through: 15
1 parentc3de0f9 commit8364354

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎src/backend/replication/pgoutput/pgoutput.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,8 +1184,8 @@ init_tuple_slot(PGOutputData *data, Relation relation,
11841184
TupleDescindesc=RelationGetDescr(relation);
11851185
TupleDescoutdesc=RelationGetDescr(ancestor);
11861186

1187-
/* Map must live as long as thesession does. */
1188-
oldctx=MemoryContextSwitchTo(CacheMemoryContext);
1187+
/* Map must live as long as thelogical decoding context. */
1188+
oldctx=MemoryContextSwitchTo(data->cachectx);
11891189

11901190
entry->attrmap=build_attrmap_by_name_if_req(indesc,outdesc, false);
11911191

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp