Fix memory leak in pgoutput for the WAL sender
authorMichael Paquier <michael@paquier.xyz>
Thu, 21 Nov 2024 06:14:02 +0000 (15:14 +0900)
committerMichael Paquier <michael@paquier.xyz>
Thu, 21 Nov 2024 06:14:02 +0000 (15:14 +0900)
commitea792bfd93ab8ad4ef4e3d1a741b8595db143677
treec32b3490d81f31e2156a4d08b62f964693101ba4
parentf95da9f0e091ddbc5d50ec6c11be772da009b24e
Fix memory leak in pgoutput for the WAL sender

RelationSyncCache, the hash table in charge of tracking the relation
schemas sent through pgoutput, was forgetting to free the TupleDesc
associated to the two slots used to store the new and old tuples,
causing some memory to be leaked each time a relation is invalidated
when the slots of an existing relation entry are cleaned up.

This is rather hard to notice as the bloat is pretty minimal, but a
long-running WAL sender would be in trouble over time depending on the
workload.  sysbench has proved to be pretty good at showing the problem,
coupled with some memory monitoring of the WAL sender.

Issue introduced in 52e4f0cd472d, that has added row filters for tables
logically replicated.

Author: Boyu Yang
Reviewed-by: Michael Paquier, Hou Zhijie
Discussion: https://postgr.es/m/DM3PR84MB3442E14B340E553313B5C816E3252@DM3PR84MB3442.NAMPRD84.PROD.OUTLOOK.COM
Backpatch-through: 15
src/backend/replication/pgoutput/pgoutput.c