Re: Memory leak of SMgrRelation object on standby

邱宇航 <iamqyh@gmail.com>

From: 邱宇航 <iamqyh@gmail.com>
To: Jingtang Zhang <mrdrivingduck@gmail.com>
Cc: Thomas Munro <thomas.munro@gmail.com>, PostgreSQL-development <pgsql-hackers@postgresql.org>, pgsql-hackers@lists.postgresql.org
Date: 2025-09-09T03:58:51Z
Lists: pgsql-hackers
> 2025年8月26日 11:59,Jingtang Zhang <mrdrivingduck@gmail.com> 写道:
> 
> Hi~
> 
>> I purpose a patch which calls smgrdestroyall() when redo each
>> XLOG_CHECKPOINT_ONLINE, so that it can keep the same frequency of calling
>> smgrdestroyall() as background processes on primary. I don't call it for
>> XLOG_CHECKPOINT_SHUTDOWN because the process is about to exit so that the
>> memory will go soon, and don't call it for XLOG_CHECKPOINT_REDO because it
>> seems to be a place holder only.
> 
> 
> Oops. When redo XLOG_CHECKPOINT_SHUTDOWN, smgrdestroyall should also be
> called, since the startup may not exit on standby.
> 
> The patch is updated.
> 
> —
> Regards, Jingtang
> 
> <v4-0001-Fix-SMgrRelation-object-memory-leak-during-startup-r.patch>

LGTM.

Best regards,
Yuhang Qiu




Commits

  1. Fix leak with SMgrRelations in startup process

  2. Give SMgrRelation pointers a well-defined lifetime.