postgresql/src
Michael Paquier da8bd5d424 Fix memory leak in pgoutput with relation attribute map
pgoutput caches the attribute map of a relation, that is free()'d only
when validating a RelationSyncEntry.  However, this code path is not
taken when calling any of the SQL functions able to do some logical
decoding, like pg_logical_slot_{get,peek}_changes(), leaking some memory
into CacheMemoryContext on repeated calls.

To address this, a relation's attribute map is allocated in
PGOutputData's cachectx, free()'d at the end of the execution of these
SQL 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 Sawada
Author: Vignesh C
Reviewed-by: Hou Zhijie
Discussion: https://postgr.es/m/CAD21AoDkAhQVSukOfH3_reuF-j4EU0-HxMqU3dU+bSTxsqT14Q@mail.gmail.com
Discussion: https://postgr.es/m/CALDaNm1hewNAsZ_e6FF52a=9drmkRJxtEPrzCB6-9mkJyeBBqA@mail.gmail.com
Backpatch-through: 15
2024-12-30 13:34:01 +09:00
..
backend Fix memory leak in pgoutput with relation attribute map 2024-12-30 13:34:01 +09:00
bin pgbench: fix misprocessing of some nested \if constructs. 2024-12-15 14:14:15 -05:00
common Replace pgwin32_is_junction() with lstat(). 2024-11-08 09:29:40 +10:30
fe_utils Prevent mis-encoding of "trailing junk after numeric literal" errors. 2024-09-05 12:42:33 -04:00
include Exclude parallel workers from connection privilege/limit checks. 2024-12-28 16:08:50 -05:00
interfaces Fix broken list-munging in ecpg's remove_variables(). 2024-12-01 14:15:37 -05:00
makefiles Refactor DLSUFFIX handling 2022-03-25 08:56:02 +01:00
pl Add support for Tcl 9 2024-11-25 12:27:26 +01:00
port Make unlink() work for junction points on Windows. 2024-11-08 09:30:09 +10:30
template On NetBSD, force dynamic symbol resolution at postmaster start. 2022-08-30 17:28:55 -04:00
test Fix handling of orphaned 2PC files in the future at recovery 2024-12-30 08:06:43 +09:00
timezone Update time zone data files to tzdata release 2024b. 2024-10-29 11:50:00 -04:00
tools Skip SectionMemoryManager.h in cpluspluscheck. 2024-11-28 15:47:17 +13:00
tutorial Doc: sync src/tutorial/basics.source with SGML documentation. 2022-11-19 13:09:14 -05:00
.gitignore
DEVELOPERS
Makefile Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00
Makefile.global.in Suppress macOS warnings about duplicate libraries in link commands. 2023-09-29 14:07:30 -04:00
Makefile.shlib Stop using "-multiply_defined suppress" on macOS. 2023-09-26 21:06:21 -04:00
nls-global.mk Improve frontend error logging style. 2022-04-08 14:55:14 -04:00