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 leak with SMgrRelations in startup process
Date: Tue, 09 Sep 2025 22:23:55 +0000
Message-ID: <E1uw6kl-001Udj-1B@gemulon.postgresql.org> (raw)

Fix leak with SMgrRelations in startup process

The startup process does not process shared invalidation messages, only
sending them, and never calls AtEOXact_SMgr() which clean up any
unpinned SMgrRelations.  Hence, it is never able to free SMgrRelations
on a periodic basis, bloating its hashtable over time.

Like the checkpointer and the bgwriter, this commit takes a conservative
approach by freeing periodically SMgrRelations when replaying a
checkpoint record, either online or shutdown, so as the startup process
has a way to perform a periodic cleanup.

Issue caused by 21d9c3ee4ef7, so backpatch down to v17.

Author: Jingtang Zhang <mrdrivingduck@gmail.com>
Reviewed-by: Yuhang Qiu <iamqyh@gmail.com>
Discussion: https://postgr.es/m/28C687D4-F335-417E-B06C-6612A0BD5A10@gmail.com
Backpatch-through: 17

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8c8f7b199d9095dbc2e101a4614043b5ae13bde3

Modified Files
--------------
src/backend/access/transam/xlog.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)



view thread (3+ messages)  latest in thread

Message-ID: <E1uw6kl-001Udj-1B@gemulon.postgresql.org>
Permalink:  ../E1uw6kl-001Udj-1B@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1uw6kl-001Udj-1B@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 leak with SMgrRelations in startup process
  In-Reply-To: <E1uw6kl-001Udj-1B@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