pgsql: Fix CheckPointReplicationSlots() with max_replication_slots == 0

From: Alexander Korotkov <akorotkov(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix CheckPointReplicationSlots() with max_replication_slots == 0
Date: 2025-06-27 08:49:15
Message-ID: E1uV4ln-003Ymx-0f@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix CheckPointReplicationSlots() with max_replication_slots == 0

ca307d5cec90 made CheckPointReplicationSlots() unconditionally call
ReplicationSlotsComputeRequiredLSN(). It causes an assertion trap when
max_replication_slots equals 0. This commit makes
CheckPointReplicationSlots() call ReplicationSlotsComputeRequiredLSN() only
when at least one slot gets its last_saved_restart_lsn updated. That avoids
an assert trap and also saves some cycles when no one slot has
last_saved_restart_lsn updated.

Based on ideas from Dilip Kumar <dilipbalaut(at)gmail(dot)com> and
Hayato Kuroda <kuroda(dot)hayato(at)fujitsu(dot)com>.

Reported-by: Zhijie Hou <houzj(dot)fnst(at)fujitsu(dot)com>
Discussion: https://postgr.es/m/OS0PR01MB5716BB506AF934376FF3A8BB947BA%40OS0PR01MB5716.jpnprd01.prod.outlook.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7195c804bd12f47a9f1b2df9c2e1794bb04c5987

Modified Files
--------------
src/backend/replication/slot.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tomas Vondra 2025-06-27 14:52:08 Re: pgsql: Introduce pg_shmem_allocations_numa view
Previous Message Michael Paquier 2025-06-27 00:34:50 pgsql: Correct list of files in src/backend/lib/README