agora inbox for [email protected]  
help / color / mirror / Atom feed
From: Bertrand Drouvot <[email protected]>
Subject: [PATCH v1] Adding LWLock protection in pgstat_reset_replslot()
Date: Fri, 1 Mar 2024 10:04:17 +0000

pgstat_reset_replslot() is missing a LWLock protection as we don't have any
guarantee that the slot is active (then preventing it to be dropped/recreated)
when this function is executed.
---
 src/backend/utils/activity/pgstat_replslot.c | 4 ++++
 1 file changed, 4 insertions(+)
 100.0% src/backend/utils/activity/

diff --git a/src/backend/utils/activity/pgstat_replslot.c b/src/backend/utils/activity/pgstat_replslot.c
index 70cabf2881..a113e1c486 100644
--- a/src/backend/utils/activity/pgstat_replslot.c
+++ b/src/backend/utils/activity/pgstat_replslot.c
@@ -46,6 +46,8 @@ pgstat_reset_replslot(const char *name)
 
 	Assert(name != NULL);
 
+	LWLockAcquire(ReplicationSlotControlLock, LW_SHARED);
+
 	/* Check if the slot exits with the given name. */
 	slot = SearchNamedReplicationSlot(name, true);
 
@@ -65,6 +67,8 @@ pgstat_reset_replslot(const char *name)
 	/* reset this one entry */
 	pgstat_reset(PGSTAT_KIND_REPLSLOT, InvalidOid,
 				 ReplicationSlotIndex(slot));
+
+	LWLockRelease(ReplicationSlotControlLock);
 }
 
 /*
-- 
2.34.1


--UhmNP5I6UQFh4Sd8--





view thread (12+ messages)  latest in thread

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: [PATCH v1] Adding LWLock protection in pgstat_reset_replslot()
  In-Reply-To: <no-message-id-1854629@localhost>

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

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