| From: | Adesh Thakare <adeshthakare10(at)gmail(dot)com> |
|---|---|
| To: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
| Cc: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, "T, Adesh" <adeshdb(at)amazon(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Postmaster PANIC on a standby with slot synchronization enabled |
| Date: | 2026-12-02 01:40:38 |
| Message-ID: | CAFoBUgKMPzg=MC23MFVbEctTLDoTFGL9JYQJ-oemWK_dichxOQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On Wed, Nov 25, 2026 at 4:23 PM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
wrote:
I think it's better to limit the use of the new function to the
postmaster. IsUnderPostmater is false also in a standalone backend.
Done. ValidateSlotSyncParams() now uses IsLogicalDecodingEnabledNoLock()
only when IsPostmasterEnvironment && !IsUnderPostmaster.
I'm not sure we need this check. Logical decoding can be disabled right
after this check too, so it doesn't close the race.
Agreed, removed. Bharath, I know you asked to keep it; I went with the
smaller change since this is going back to v19.
v6 is also rebased on current master; v4 no longer applied after
4931dab89d3. 0002 is still the test, not for commit.
Thanks,
Adesh
On Wed, Nov 25, 2026 at 4:23 PM Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
wrote:
> On Wed, Nov 25, 2026 at 2:58 PM Adesh Thakare <adeshthakare10(at)gmail(dot)com>
> wrote:
> >
> > Hi,
> >
> > Thanks, both, for the review. Attached is v4. (Sorry, my mail system
> > replaced the v2 attachments with download links; these are attached
> > directly.)
> >
> > Sawada-san: as you suggested, there is now an explicit
> > IsLogicalDecodingEnabledNoLock(), which ValidateSlotSyncParams() uses
> > when it runs in the postmaster. IsLogicalDecodingEnabled() always takes
> the lock.
> >
> > Bharath: I've addressed your comments:
> >
> > 1. The worker recheck now runs after the sigsetjmp block and calls
> > ValidateSlotSyncParams(ERROR).
> > 2. I used your simpler comments.
> > 3. The comment on LogicalDecodingCtlData now says that the postmaster
> > reads logical_decoding_enabled without the lock.
> > 4. 0002 (injection point + TAP test) is still there for the record only,
> > not for commit.
>
> Thank you for updating the patch! I've reviewed the new patch and here
> are comments:
>
> + if (IsUnderPostmaster)
> + logical_decoding_enabled = IsLogicalDecodingEnabled();
> + else
> + logical_decoding_enabled = IsLogicalDecodingEnabledNoLock();
>
> I think it's better to limit the use of the new function to the
> postmaster. IsUnderPostmater is false also in a standalone backend.
> How about rewriting this part to:
>
> if (IsPostmasterEnvironment && !IsUnderPostmaster)
> logical_decoding_enabled = IsLogicalDecodingEnabledNoLock();
> else
> logical_decoding_enabled = IsLogicalDecodingEnabled();
>
> ---
> + /*
> + * The postmaster checked the logical decoding status without the lock
> + * (see IsLogicalDecodingEnabledNoLock()), so confirm it is still
> enabled.
> + */
> + ValidateSlotSyncParams(ERROR);
>
> I'm not sure we need this check. Logical decoding can be disabled
> right after this check too, so it doesn't close the race. And we
> already keep the slotsync worker running even after logical decoding
> is disabled. Given that the fix needs to be backpatched to v19, I'd
> prefer not to add a new exit path to the worker.
>
> Regards,
>
> --
> Masahiko Sawada
> Amazon Web Services: https://aws.amazon.com
>
| Attachment | Content-Type | Size |
|---|---|---|
| v6-0002-Add-a-test-for-the-postmaster-waiting-on-LogicalD.patch | application/octet-stream | 6.4 KB |
| v6-0001-Don-t-wait-for-LogicalDecodingControlLock-in-the-.patch | application/octet-stream | 4.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chao Li | 2026-12-02 01:44:17 | Re: pg_upgrade: backslash escaping in check_for_unicode_update() |
| Previous Message | Jelte Fennema-Nio | 2026-12-02 01:08:58 | Re: Reapply graceful socket shutdown on Windows (revert 29992a6a509) |