RE: Bound memory usage during manual slot sync retries

From: "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>
To: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "itsajin(at)gmail(dot)com" <itsajin(at)gmail(dot)com>, Khoa Nguyen <kdnguyen9(dot)oss(at)gmail(dot)com>
Subject: RE: Bound memory usage during manual slot sync retries
Date: 2026-05-29 02:59:54
Message-ID: TY4PR01MB17718C9178B896C25ED4CCE4C94162@TY4PR01MB17718.jpnprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Friday, May 29, 2026 10:31 AM Xuneng Zhou <xunengzhou(at)gmail(dot)com> wrote:
>
> On Fri, May 29, 2026 at 12:43 AM Khoa Nguyen <kdnguyen9(dot)oss(at)gmail(dot)com>
> wrote:
> >
> > I also reviewed the script and it is well done. The script setup and
> > capture data points showing memory leak within the session over time.
> > The patch looks fine though I think that oldctx should be captured
> > once outside the retry loop since the current logic is more about
> > parent and child memory context rather than previous and current
> > context. Nevertheless, the current code works as well.
>
> Thanks for your review and verification. I agree with your suggestion
> that capturing the outer memory context once outside the retry loop
> looks cleaner and reflect the lifetime model better. I am also
> wondering whether renaming the oldctx to outerctx could express the
> parent/child relationship more clearly. That said, I am ok with the
> status quo, if Amit thinks no further modification is needed.

I am personally -1 on this change. The patch makes the logic somewhat harder for
me to follow and understand. IIUC, the patch assumes that all code executed
after creating sync_retry_ctx should fall under the 'outerctx'. This assumption
seems fragile as it could easily be broken if someone creates another temp
context and places the entire loop logic inside that context.

Best Regards,
Hou zj

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Fujii Masao 2026-05-29 03:11:38 Re: ECPG: inconsistent behavior with the document in “GET/SET DESCRIPTOR.”
Previous Message Adam Brusselback 2026-05-29 02:53:15 Re: [Patch] Add WHERE clause support to REFRESH MATERIALIZED VIEW