Re: DOCS - pg_replication_slot . Fix the 'inactive_since' description

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Peter Smith <smithpb2250(at)gmail(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, shveta(dot)malik(at)gmail(dot)com, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: DOCS - pg_replication_slot . Fix the 'inactive_since' description
Date: 2024-10-16 17:26:57
Message-ID: Zw_3YbgAIyZlokCV@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Sep 9, 2024 at 01:15:32PM +1000, Peter Smith wrote:
> On Mon, Sep 9, 2024 at 12:20 PM David G. Johnston
> <david(dot)g(dot)johnston(at)gmail(dot)com> wrote:
> >
> >
> >
> > On Sun, Sep 8, 2024, 18:55 Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
> >>
> >> Saying "The time..." is fine, but the suggestions given seem backwards to me:
> >> - The time this slot was inactivated
> >> - The time when the slot became inactive.
> >> - The time when the slot was deactivated.
> >>
> >> e.g. It is not like light switch. So, there is no moment when the
> >> active slot "became inactive" or "was deactivated".
> >
> >
> > While this is plausible the existing wording and the name of the field definitely fail to convey this.
> >
> >>
> >> Rather, the 'inactive_since' timestamp field is simply:
> >> - The time the slot was last active.
> >> - The last time the slot was active.
> >
> >
> > I see your point but that wording is also quite confusing when an active slot returns null for this field.
> >
> > At this point I'm confused enough to need whatever wording is taken to be supported by someone explaining the code that interacts with this field.
> >
>
> Me too. I created this thread primarily to get the description changed
> to clarify this field represents a moment in time, rather than a
> duration. So I will be happy with any wording that addresses that.

I dug into the code and came up with the attached patch. "active" means
there is a process streaming the slot, and the "inactive_since" time
means the last time synchronous slot streaming was stopped. Doc patch
attached.

I am not sure what other things are needed, but this is certainly
unclear. This comment from src/backend/replication/logical/slotsync.c
helped me understand this:

* We need to update inactive_since only when we are promoting standby to
* correctly interpret the inactive_since if the standby gets promoted
* without a restart. We don't want the slots to appear inactive for a
* long time after promotion if they haven't been synchronized recently.
* Whoever acquires the slot, i.e., makes the slot active, will reset it.

--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EDB https://enterprisedb.com

When a patient asks the doctor, "Am I going to die?", he means
"Am I going to die soon?"

Attachment Content-Type Size
inactive.diff text/x-diff 3.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Yurii Rashkovskii 2024-10-16 17:28:59 Failing assertion in predicate.c
Previous Message Jacob Champion 2024-10-16 17:21:54 Re: [PoC] Federated Authn/z with OAUTHBEARER