Re: Function to get invalidation cause of a replication slot.

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: "Drouvot, Bertrand" <bertranddrouvot(dot)pg(at)gmail(dot)com>, shveta malik <shveta(dot)malik(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Function to get invalidation cause of a replication slot.
Date: 2023-12-21 06:23:04
Message-ID: CAA4eK1JcfBaMhrk7mrsj7-9g6p3KCBa7iBULjBBkw2ETD1NPzQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Dec 21, 2023 at 11:18 AM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Thu, Dec 21, 2023 at 09:37:39AM +0530, Amit Kapila wrote:
> > It depends on how one uses the function. For example, if one finds
> > there is a conflict via pg_get_replication_slots() and wants to check
> > the reason for the same via this new function then it would give the
> > correct answer.
>
> My point is that we may not get the "correct" answer at all :/
>
> What guarantee do you have that between the scan of
> pg_get_replication_slots() to get the value of "conflicting" and the
> call of pg_get_slot_invalidation_cause() the slot state will still be
> the same?
>

Yeah, if one uses them independently then there is no such guarantee.

> A lot could happen between both function calls while the
> repslot LWLock is not hold.
>
> > Now, if we think it is okay to have two columns
> > 'conflicting' and 'conflict_reason/conflict_cause' to be returned by
> > pg_get_replication_slots() then that should serve the purpose as well
> > but one can argue that 'conflicting' is deducible from
> > 'conflict_reason'.
>
> Yeah, you could keep the reason text as NULL when there is no
> conflict, replacing the boolean by the text in the function, and keep
> the view definition compatible with v16 while adding an extra column.
>

But as mentioned we also want the enum value to be exposed in some way
so that it can be used by the sync slot feature [1] as well,
otherwise, we may need some mappings to convert the text back to an
enum. I guess if we want to expose via view, then we can return an
enum value by pg_get_replication_slots() and the view can replace it
with text based on the value.

[1] - https://www.postgresql.org/message-id/OS0PR01MB5716DAF72265388A2AD424119495A%40OS0PR01MB5716.jpnprd01.prod.outlook.com

--
With Regards,
Amit Kapila.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2023-12-21 06:24:18 Re: GUC names in messages
Previous Message Amit Kapila 2023-12-21 06:16:35 Re: speed up a logical replica setup