Re: Bound memory usage during manual slot sync retries

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Xuneng Zhou <xunengzhou(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, itsajin(at)gmail(dot)com, "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>
Subject: Re: Bound memory usage during manual slot sync retries
Date: 2026-05-15 09:23:30
Message-ID: CAA4eK1+4KCedvh1AWuWf_A9AvS79Jdt8Mu-22ofKV143gEu8Ow@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, May 15, 2026 at 11:02 AM Xuneng Zhou <xunengzhou(at)gmail(dot)com> wrote:
>
> pg_sync_replication_slots() now retries inside a single SQL function
> call. Unlike the slotsync worker, it does not get a transaction boundary
> between retry cycles, so allocations made while fetching and synchronizing
> remote slots can accumulate until the function returns.
>
> The existing list_free_deep(remote_slots) is not enough to bound this.
> It frees the List cells and the RemoteSlot structs stored as list
> elements, but it does not recursively free allocations owned by those
> structs, such as the copied slot name, plugin name, and database name.
>

Right.

> It also does not release unrelated per-cycle allocations made while
> fetching and processing the remote slots.
>

BTW, did you notice via test or otherwise, what and how much other
unrelated memory is being allocated during each sync cycle if we
manually free the allocations you observed? This is mainly to learn
the impact of not doing all these allocations in some short-duration
memory context.

--
With Regards,
Amit Kapila.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-05-15 09:31:55 doc: fix pg_restore_extended_stats() example syntax
Previous Message jian he 2026-05-15 09:05:47 Re: on_error table, saving error info to a table