Re: [PATCH] Fall back to serializing when parallel apply runs out of DSM segments

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Baji Shaik <baji(dot)pgdev(at)gmail(dot)com>
Cc: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Zhijie Hou <houzhijie22(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] Fall back to serializing when parallel apply runs out of DSM segments
Date: 2026-11-17 22:52:46
Message-ID: CAD21AoCSmyK83FnrOgcBGb9sdit_fU7yWYmp-O2iua039gQg0A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Nov 11, 2026 at 10:37 AM Baji Shaik <baji(dot)pgdev(at)gmail(dot)com> wrote:
>
> On Wed, Nov 11, 2026 at 11:46 AM Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
>>
>>
>> I have a slightly different opinion here. I understand that a leader
>> erroring out while launching parallely apply workers has costs.
>> However, DSM running out of segments, IMO, is rare in practice and the
>> issue is not reported from the field. Even if it is hit in practice,
>> the recovery from that error is automatic for the apply worker starts
>> again and callers of make_new_segment() would hit OOM or similar error
>> anyway. I would just apply it for HEAD and be done with it.
>
>
> Thanks for the review, Bharath. HEAD only works for me.
> I will leave the back-patching decision to the committer.
>

I've reviewed both patches and both look good to me.

Regarding backpatching these patches, I'm inclined to backpatch both
of them. Regarding the parallel apply worker issue, it seems a bug to
me. As for the 0001 patch, the apply worker would restart even in the
problematic case, but it could error out again as it receives STREAM
START and cannot create a new DSM because all segments are still in
use. Therefore the replication would stop, which violates what the
documentation says.

Regarding the 0002 patch, it simply violates what DSA_ALLOC_NO_OOM
promises. IIUC make_new_segment() is implemented to exit gracefully
even in erroneous cases so that its caller can handle the situation. A
caller using DSA_ALLOC_NO_OOM gets an error if DSM slots are used up,
instead of InvalidDsaPointer.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2026-11-17 23:15:50 Re: Initial table sync copies the whole table when it is no longer published
Previous Message Melanie Plageman 2026-11-17 22:47:48 Re: WAL_LOG CREATE DATABASE strategy broken for non-standard page layouts