Re: Clear logical slot's 'synced' flag on promotion of standby

From: shveta malik <shveta(dot)malik(at)gmail(dot)com>
To: Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>
Cc: Ajin Cherian <itsajin(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, shveta malik <shveta(dot)malik(at)gmail(dot)com>
Subject: Re: Clear logical slot's 'synced' flag on promotion of standby
Date: 2025-09-12 03:42:36
Message-ID: CAJpy0uAaeD2=EoiRm8WRJ_ft8g8mE95mGWQkouHPhHhFdVA7aQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Sep 11, 2025 at 3:16 PM Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com> wrote:
>
> Hi,
>
>
> We already read the recovery signal files (standby.signal or
> recovery.signal) at the start of StartupXLOG() via InitWalRecovery(),
> which sets the StandbyModeRequested flag. Couldn’t we use this to
> distinguish whether the server is a primary undergoing crash recovery
> or a standby?
>

The objective is not to distinguish between a primary and a standby
undergoing crash recovery, but to differentiate between a primary
undergoing crash recovery and a promoted standby (now the new primary)
during the immediate next startup—specifically in cases where the
promotion failed late in the process, such as during ResetSyncedSlots.
StandbyModeRequested will be false in both the cases and thus cannot
be used.

> >
> >
> I attempted to
> > simulate a scenario where a regular standby ends up in
> > DB_IN_CRASH_RECOVERY after a crash, but I couldn't reproduce it. Do
> > you know of any situation where this could happen? The absence of
> > comments for these states makes it challenging to follow the flow.
> >
>
> The log message for "case DB_IN_CRASH_RECOVERY:" inside StartupXLOG
> should indicate that the server has entered crash recovery, no? And..
> If you still want the server to crash while in this state, you could
> add your own PANIC or FATAL error message inside the startupxlog.
>

I think my query was not correctly understood. The intent was to know
if we can ever hit 'DB_IN_CRASH_RECOVERY' on a regular standby. But, I
think the answer is 'No'. We can hit it on primary (before , during,
or after promotion after a crash).

thanks
Shveta

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2025-09-12 03:56:41 Re: Clear logical slot's 'synced' flag on promotion of standby
Previous Message Chao Li 2025-09-12 03:33:17 Re: Checkpointer write combining