Re: BUG: Former primary node might stuck when started as a standby - Mailing list pgsql-hackers

From Alexander Lakhin
Subject Re: BUG: Former primary node might stuck when started as a standby
Date
Msg-id 74ea5e7e-9aa0-4d7a-85df-71a9d200a8d8@gmail.com
Whole thread Raw
In response to Re: BUG: Former primary node might stuck when started as a standby  (Aleksander Alekseev <aleksander@timescale.com>)
Responses Re: BUG: Former primary node might stuck when started as a standby
List pgsql-hackers
Hi Aleksander,

19.01.2024 14:45, Aleksander Alekseev wrote:
>
>> it might not go online, due to the error:
>> new timeline N forked off current database system timeline M before current recovery point X/X
>> [...]
>> In this case, node1 wrote to it's WAL record 0/304DC68, but sent to node2
>> only record 0/304DBF0, then node2, being promoted to primary, forked a next
>> timeline from it, but when node1 was started as a standby, it first
>> replayed 0/304DC68 from WAL, and then could not switch to the new timeline
>> starting from the previous position.
> Unless I'm missing something, this is just the right behavior of the system.

Thank you for the answer!

> node1 has no way of knowing the history of node1/node2/nodeN
> promotion. It sees that it has more data and/or inconsistent timeline
> with another node and refuses to process further until DBA will
> intervene.

But node1 knows that it's a standby now and it's expected to get all the
WAL records from the primary, doesn't it?
Maybe it could REDO from it's own WAL as little records as possible,
before requesting records from the authoritative source...
Is it supposed that it's more performance-efficient (not on the first
restart, but on later ones)?

>   What else can node1 do, drop the data? That's not how
> things are done in Postgres :)

In case no other options exist (this behavior is really correct and the
only possible), maybe the server should just stop?
Can DBA intervene somehow to make the server proceed without stopping it?

> It's been a while since I seriously played with replication, but if
> memory serves, a proper way to switch node1 to a replica mode would be
> to use pg_rewind on it first.

Perhaps that's true generally, but as we can see, without the extra
records replayed, this scenario works just fine. Moreover, existing tests
rely on it, e.g., 009_twophase.pl or 012_subtransactions.pl (in fact, my
research of the issue was initiated per a test failure).

Best regards,
Alexander



pgsql-hackers by date:

Previous
From: David Steele
Date:
Subject: Re: Use of backup_label not noted in log
Next
From: Peter Eisentraut
Date:
Subject: Re: Build versionless .so for Android