Re: Memory leak of SMgrRelation object on standby
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: 邱宇航 <iamqyh@gmail.com>
Cc: Jingtang Zhang <mrdrivingduck@gmail.com>, Thomas Munro <thomas.munro@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>, pgsql-hackers@lists.postgresql.org
Date: 2025-09-09T05:49:12Z
Lists: pgsql-hackers
On Tue, Sep 09, 2025 at 11:58:51AM +0800, 邱宇航 wrote: >> Oops. When redo XLOG_CHECKPOINT_SHUTDOWN, smgrdestroyall should also be >> called, since the startup may not exit on standby. >> >> The patch is updated. True that the situation sucks for the startup process, bloating its memory. That's hard to reach, still for long-running startup processes, which is a common thing, that's rather bad. > LGTM. Hmm. I was playing a bit with the startup process and, after planting a few calls to hash_get_num_entries(SMgrRelationHash) the bloat is measurable. On wraparound, it would mean that the hash table could point to past entries in this context. I can get behind the patch and the proposal of forcing a cleanup each time a checkpoint record is replayed, outside of RecoveryRestartPoint(), so I'll see about applying and backpatching that. Thanks for the report. -- Michael
Commits
-
Fix leak with SMgrRelations in startup process
- e2dd7b2acf27 17.7 landed
- 039301b3fceb 18.0 landed
- 8c8f7b199d90 19 (unreleased) landed
-
Give SMgrRelation pointers a well-defined lifetime.
- 21d9c3ee4ef7 17.0 cited