Re: Memory leak of SMgrRelation object on standby

From: Jingtang Zhang <mrdrivingduck(at)gmail(dot)com>
To: 邱宇航 <iamqyh(at)gmail(dot)com>
Cc: 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-08-25 15:56:28
Message-ID: 1C2328C9-1FA5-4AA5-8929-9EE5966C7246@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi~

> Agree with that. Maybe we can call smgrdestroyall in startup process when
> replaying CHECKPOINT records, just like bgwriter/checkpointer, which free
> all smgr objects after any checkpoint.

That seems reasonable, in that case a startup process would behave just the
same as bgwriter or checkpointer.

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.


Regards, Jingtang

Attachment Content-Type Size
v3-0001-Fix-SMgrRelation-object-memory-leak-during-startup-r.patch application/octet-stream 999 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Treat 2025-08-25 16:03:03 Re: Adding REPACK [concurrently]
Previous Message Thomas Munro 2025-08-25 15:43:04 Re: index prefetching