Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 77cf6a7

Browse files
committed
Add some asserts based on LWLockHeldByMe() for replication slot statistics
Two assertions checking that ReplicationSlotAllocationLock is acquired are added to pgstat_create_replslot() and pgstat_drop_replslot(), corresponding to the routines in charge of the creation and the drop of replication slot statistics. The code previously relied on this assumption and documented it in comments, but did not enforce this policy at runtime. Reviewed-by: Bertrand Drouvot Discussion: https://postgr.es/m/Ze_p-hmD_yFeVYXg@paquier.xyz
1 parent 32dd2c1 commit 77cf6a7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/backend/utils/activity/pgstat_replslot.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ pgstat_create_replslot(ReplicationSlot *slot)
113113
PgStat_EntryRef *entry_ref;
114114
PgStatShared_ReplSlot *shstatent;
115115

116+
Assert(LWLockHeldByMeInMode(ReplicationSlotAllocationLock, LW_EXCLUSIVE));
117+
116118
entry_ref = pgstat_get_entry_ref_locked(PGSTAT_KIND_REPLSLOT, InvalidOid,
117119
ReplicationSlotIndex(slot), false);
118120
shstatent = (PgStatShared_ReplSlot *) entry_ref->shared_stats;
@@ -153,6 +155,8 @@ pgstat_acquire_replslot(ReplicationSlot *slot)
153155
void
154156
pgstat_drop_replslot(ReplicationSlot *slot)
155157
{
158+
Assert(LWLockHeldByMeInMode(ReplicationSlotAllocationLock, LW_EXCLUSIVE));
159+
156160
pgstat_drop_entry(PGSTAT_KIND_REPLSLOT, InvalidOid,
157161
ReplicationSlotIndex(slot));
158162
}

0 commit comments

Comments
 (0)