pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: shveta malik <shveta.malik@gmail.com>
Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: Amit Kapila <akapila@postgresql.org>
Cc: pgsql-hackers@postgresql.org <pgsql-hackers@postgresql.org>
Subject: Re: pgsql: Track last_inactive_time in pg_replication_slots.
Date: Mon, 25 Mar 2024 15:16:54 +0000
Message-ID: <ZgGVZiZnvqRTDodo@ip-10-97-1-34.eu-west-3.compute.internal> (raw)
In-Reply-To: <CAA4eK1+KAZoLBaPqnr8e8icF30fBMX1QwOBjYfLCZKXF_WRGnw@mail.gmail.com>
References: <E1roiEh-005Z7e-88@gemulon.postgresql.org>
	<CA+Tgmob_Ta-t2ty8QrKHBGnNLrf4ZYcwhGHGFsuUoFrAEDw4sA@mail.gmail.com>
	<CAA4eK1Ld9bSm1gEYD2_B78tkjhSpfG+ON-iJ7E3NiH5RLYtPOQ@mail.gmail.com>
	<CA+TgmoaCA-aaBiszkMKOTn6C3BKkY4hNAdNOLUhfMXdQxyrh9g@mail.gmail.com>
	<CAA4eK1+KAZoLBaPqnr8e8icF30fBMX1QwOBjYfLCZKXF_WRGnw@mail.gmail.com>

Hi,

On Mon, Mar 25, 2024 at 08:38:16PM +0530, Amit Kapila wrote:
> On Mon, Mar 25, 2024 at 7:51 PM Robert Haas <robertmhaas@gmail.com> wrote:
> >
> > On Mon, Mar 25, 2024 at 10:02 AM Amit Kapila <amit.kapila16@gmail.com> wrote:
> > > We considered the other two names as last_inactive_at and
> > > last_active_time. For the first (last_inactive_at), there was an
> > > argument that most other fields that display time ends with _time. For
> > > the second (last_active_time), there was an argument that it could be
> > > misleading as one could think that it should be updated each time WAL
> > > record decoding is happening [1]. The other possibility is to name it
> > > last_used_time but I think it won't be much different from
> > > last_active_time.
> >
> > I don't understand the bit about updating it each time WAL record
> > decoding is happening. If it's the last active time, and the slot is
> > currently active, then the answer is either "right now" or "currently
> > undefined." I'd expect to see NULL in the system view in such a case.
> > And if that's so, then there's nothing to update each time a record is
> > decoded, because it's just still going to show NULL.
> >
> 
> IIUC, Bertrand's point was that users can interpret last_active_time
> as a value that gets updated each time they decode a change which is
> not what we are doing. So, this can confuse users. Your expectation of
> answer (NULL) when the slot is active is correct and that is what will
> happen.

Yeah, and so would be the confusion: why is last_active_time NULL while one is
using the slot?

> > Why does this field get set to the current time when the slot is
> > restored from disk?
> >
> 
> It is because we don't want to include the time the server is down in
> the last_inactive_time. Say, if we are shutting down the server at
> time X and the server remains down for another two hours, we don't
> want to include those two hours as the slot inactive time. The related
> theory is that this field will be used to invalidate inactive slots
> based on a threshold (say inactive_timeout). Say, before the shutdown,
> we release the slot and set the current_time for last_inactive_time
> for each slot and persist that information as well. Now, if the server
> is down for a long time, we may invalidate the slots as soon as the
> server comes up. So, instead, we just set this field at the time we
> read slots for disk and then reset it to 0/NULL as soon as the slot
> became active.

Right, and we also want to invalidate the slot if not used duration > timeout,
so that setting the field to zero when the slot is restored from disk is also not
an option.

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com





view thread (34+ messages)  latest in thread

Message-ID: <ZgGVZiZnvqRTDodo@ip-10-97-1-34.eu-west-3.compute.internal>
Permalink:  ../ZgGVZiZnvqRTDodo@ip-10-97-1-34.eu-west-3.compute.internal/
Also on:    postgresql.org/message-id/ZgGVZiZnvqRTDodo@ip-10-97-1-34.eu-west-3.compute.internal

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: bertranddrouvot.pg@gmail.com, amit.kapila16@gmail.com, robertmhaas@gmail.com, shveta.malik@gmail.com, bharath.rupireddyforpostgres@gmail.com, akapila@postgresql.org, pgsql-hackers@postgresql.org
  Subject: Re: pgsql: Track last_inactive_time in pg_replication_slots.
  In-Reply-To: <ZgGVZiZnvqRTDodo@ip-10-97-1-34.eu-west-3.compute.internal>
  References: <E1roiEh-005Z7e-88@gemulon.postgresql.org> <CA+Tgmob_Ta-t2ty8QrKHBGnNLrf4ZYcwhGHGFsuUoFrAEDw4sA@mail.gmail.com> <CAA4eK1Ld9bSm1gEYD2_B78tkjhSpfG+ON-iJ7E3NiH5RLYtPOQ@mail.gmail.com> <CA+TgmoaCA-aaBiszkMKOTn6C3BKkY4hNAdNOLUhfMXdQxyrh9g@mail.gmail.com> <CAA4eK1+KAZoLBaPqnr8e8icF30fBMX1QwOBjYfLCZKXF_WRGnw@mail.gmail.com> <ZgGVZiZnvqRTDodo@ip-10-97-1-34.eu-west-3.compute.internal>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox