pgsql: Avoid updating inactive_since for invalid replication slots.

From: Amit Kapila <akapila(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid updating inactive_since for invalid replication slots.
Date: 2025-02-05 03:41:08
Message-ID: E1tfWHk-005Rc2-Ed@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(dot)moond412(at)gmail(dot)com>
Author: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Reviewed-by: Vignesh C <vignesh21(at)gmail(dot)com>
Reviewed-by: Peter Smith <smithpb2250(at)gmail(dot)com>
Reviewed-by: Hou Zhijie <houzj(dot)fnst(at)fujitsu(dot)com>
Reviewed-by: Amit Kapila <amit(dot)kapila16(at)gmail(dot)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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Daniel Gustafsson 2025-02-05 13:08:46 pgsql: doc: Update links which returned 404
Previous Message Andres Freund 2025-02-04 23:19:14 pgsql: meson: Add missing dependencies to libpq_pipeline test