Re: Small fixes needed by high-availability tools

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Small fixes needed by high-availability tools
Date: 2025-05-12 05:33:26
Message-ID: CAA4eK1+c8YYQ2BFpriuo5gKArq4=KQzw+FgEm8TZzRKJQmZnBQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, May 2, 2025 at 6:30 PM Andrey Borodin <x4mmm(at)yandex-team(dot)ru> wrote:
>
> 3. Allow reading LSN written by walreciever, but not flushed yet
>
> Problem: if we have synchronous_standby_names = ANY(node1,node2), node2 might be ahead of node1 by flush LSN, but before by written LSN. If we do a failover we choose node2 instead of node1 and loose data recently committed with synchronous_commit=remote_write.
>

In which case, can we rely on written WAL that is not yet flushed?
Because say you decide based on written WAL and choose node-1 in above
case for failover, what if it restarts without flushing the written
WAL?

> Caveat: we already have a function pg_last_wal_receive_lsn(), which in fact returns flushed LSN, not written. I propose to add a new function which returns LSN actually written. Internals of this function are already implemented (GetWalRcvWriteRecPtr()), but unused.
>

It seems to me that this is less controversial than your other two
proposals. So, we can discuss this in a separate thread as well.

--
With Regards,
Amit Kapila.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2025-05-12 05:41:28 Re: Add an option to skip loading missing publication to avoid logical replication failure
Previous Message Tomas Vondra 2025-05-12 03:09:25 Re: Adding skip scan (including MDAM style range skip scan) to nbtree