Re: Memory leak of SMgrRelation object on standby - Mailing list pgsql-hackers

From Michael Paquier
Subject Re: Memory leak of SMgrRelation object on standby
Date
Msg-id aL-_2HEYj5FuqUyO@paquier.xyz
Whole thread Raw
In response to Re: Memory leak of SMgrRelation object on standby  (邱宇航 <iamqyh@gmail.com>)
List 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

Attachment

pgsql-hackers by date:

Previous
From: jian he
Date:
Subject: Re: pg_restore --no-policies should not restore policies' comment
Next
From: Dilip Kumar
Date:
Subject: Re: [PATCH] Accept connections post recovery without waiting for RemoveOldXlogFiles