| From: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
|---|---|
| To: | Adesh Thakare <adeshthakare10(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-11-26 00:23:01 |
| Message-ID: | CAD21AoDcvLdBvo+dBD+F57Qp2n6+1UATePAwVnXbR=84jrexLg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Zhijie Hou | 2026-11-26 00:32:56 | Re: Fix LogStandbySnapshot() race during logical decoding activation |
| Previous Message | Xnerv Wang | 2026-11-26 00:16:46 | Re: [PATCH] pg_input_is_valid() reuses the first type name inside a PL/pgSQL loop |