From: Amit Kapila <akapila@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid updating inactive_since for invalid replication slots.
Date: Wed, 05 Feb 2025 03:41:08 +0000
Message-ID: <E1tfWHk-005Rc2-Ed@gemulon.postgresql.org> (raw)
Avoid updating inactive_since for invalid replication slots.
It is possible for the inactive_since value of an invalid replication slot
to be updated multiple times, which is unexpected behavior like during the
release of the slot or at the time of restart. This is harmless because
invalid slots are not allowed to be accessed but it is not prudent to
update invalid slots. We are planning to invalidate slots due to other
reasons like idle time and it will look odd that the slot's inactive_since
displays the recent time in this field after invalidated due to idle time.
So, this patch ensures that the inactive_since field of slots is not
updated for invalid slots.
In the passing, ensure to use the same inactive_since time for all the
slots at restart while restoring them from the disk.
Author: Nisha Moond <nisha.moond412@gmail.com>
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Vignesh C <vignesh21@gmail.com>
Reviewed-by: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Hou Zhijie <houzj.fnst@fujitsu.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/CABdArM7QdifQ_MHmMA=Cc4v8+MeckkwKncm2Nn6tX9wSCQ-+iw@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/0ec3c295e7594ed3af86bca1a4b4be269c2f069d
Modified Files
--------------
doc/src/sgml/system-views.sgml | 3 ++-
src/backend/replication/logical/slotsync.c | 4 +---
src/backend/replication/slot.c | 21 ++++++++++-----------
src/include/replication/slot.h | 17 +++++++++++++++++
4 files changed, 30 insertions(+), 15 deletions(-)
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 using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: akapila@postgresql.org, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Avoid updating inactive_since for invalid replication slots.
In-Reply-To: <E1tfWHk-005Rc2-Ed@gemulon.postgresql.org>
* 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