postgresql/src/include/replication
Tomas Vondra 081cf78d12 Fix memory leak in TRUNCATE decoding
When decoding a TRUNCATE record, the relids array was being allocated in
the main ReorderBuffer memory context, but not released with the change
resulting in a memory leak.

The array was also ignored when serializing/deserializing the change,
assuming all the information is stored in the change itself.  So when
spilling the change to disk, we've only we have serialized only the
pointer to the relids array.  Thanks to never releasing the array,
the pointer however remained valid even after loading the change back
to memory, preventing an actual crash.

This fixes both the memory leak and (de)serialization.  The relids array
is still allocated in the main ReorderBuffer memory context (none of the
existing ones seems like a good match, and adding an extra context seems
like an overkill).  The allocation is wrapped in a new ReorderBuffer API
functions, to keep the details within reorderbuffer.c, just like the
other ReorderBufferGet methods do.

Author: Tomas Vondra
Discussion: https://www.postgresql.org/message-id/flat/66175a41-9342-2845-652f-1bd4c3ee50aa%402ndquadrant.com
Backpatch: 11, where decoding of TRUNCATE was introduced
2018-09-03 02:29:51 +02:00
..
basebackup.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
decode.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
logical.h Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
logicalfuncs.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
logicallauncher.h Add subtransaction handling for table synchronization workers. 2018-07-16 17:33:35 -04:00
logicalproto.h Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
logicalrelation.h logical replication: fix OID type mapping mechanism 2018-03-14 21:34:26 -03:00
logicalworker.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
message.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
origin.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
output_plugin.h Logical decoding of TRUNCATE 2018-04-07 11:34:10 -04:00
pgoutput.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
reorderbuffer.h Fix memory leak in TRUNCATE decoding 2018-09-03 02:29:51 +02:00
slot.h Fix and document lock handling for in-memory replication slot data 2018-06-10 19:39:26 +09:00
snapbuild.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
syncrep.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
walreceiver.h Post-feature-freeze pgindent run. 2018-04-26 14:47:16 -04:00
walsender.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
walsender_private.h Update copyright for 2018 2018-01-02 23:30:12 -05:00
worker_internal.h Update copyright for 2018 2018-01-02 23:30:12 -05:00