Re: Memory leak of SMgrRelation object on standby

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: 邱宇航 <iamqyh(at)gmail(dot)com>
Cc: Jingtang Zhang <mrdrivingduck(at)gmail(dot)com>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Memory leak of SMgrRelation object on standby
Date: 2025-09-09 05:49:12
Message-ID: aL-_2HEYj5FuqUyO@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2025-09-09 06:08:55 Re: [PATCH] Accept connections post recovery without waiting for RemoveOldXlogFiles
Previous Message jian he 2025-09-09 05:49:06 Re: pg_restore --no-policies should not restore policies' comment