pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix relcache reference leak when decoding TRUNCATE
Date: Wed, 19 Aug 2026 02:33:22 +0000
Message-ID: <E1wwW7F-0000000191m-3I3i@gemulon.postgresql.org> (raw)

Fix relcache reference leak when decoding TRUNCATE

ReorderBufferProcessTXN() opens every relation referenced by a
TRUNCATE change.  When RelationIsLogicallyLogged() returns false,
it skips the relation without releasing the reference acquired
by RelationIdGetRelation().

Looking at the in-core code paths building XLOG_HEAP_TRUNCATE records,
no relation OIDs would be included if they do not satisfy
RelationIsLogicallyLogged().  One pattern that could go through is if a
table is switched to SET UNLOGGED, but that would not be reachable in
practice as the decoding happens after a historical snapshot is taken,
so the relation should still be valid.

This is a defense-in-depth measure in practice, and we tend to be
careful about how Relations are handled when sending changes to output
plugins, so backpatch all the way down.

Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Xuneng Zhou <xunengzhou@gmail.com>
Discussion: https://postgr.es/m/7DD65D03-3B5A-43B2-99AD-8E6AF5372BAB@gmail.com
Backpatch-through: 14

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/29b52d2b47fb8fa892695bc941d3e035164481cf

Modified Files
--------------
src/backend/replication/logical/reorderbuffer.c | 3 +++
1 file changed, 3 insertions(+)



view thread (7+ messages)  latest in thread

Message-ID: <E1wwW7F-0000000191m-3I3i@gemulon.postgresql.org>
Permalink:  ../E1wwW7F-0000000191m-3I3i@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wwW7F-0000000191m-3I3i@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix relcache reference leak when decoding TRUNCATE
  In-Reply-To: <E1wwW7F-0000000191m-3I3i@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox