pgsql: Fix leak with SMgrRelations in startup process

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix leak with SMgrRelations in startup process
Date: 2025-09-09 22:23:55
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(at)gmail(dot)com>
Reviewed-by: Yuhang Qiu <iamqyh(at)gmail(dot)com>
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 17

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e2dd7b2acf27336d47f78d68f4aac03f7770a6a6

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

Browse pgsql-committers by date

  From Date Subject
Next Message Jeff Davis 2025-09-09 23:07:46 pgsql: meson: build checksums with extra optimization flags.
Previous Message Nathan Bossart 2025-09-09 19:36:57 pgsql: Fix documentation for shmem_startup_hook.