Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 77cf6a7

Browse filesBrowse 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
Copy full SHA for 77cf6a7

File tree

Expand file treeCollapse file tree

1 file changed

+4
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-0
lines changed

‎src/backend/utils/activity/pgstat_replslot.c

Copy file name to clipboardExpand all lines: src/backend/utils/activity/pgstat_replslot.c
+4Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.