Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitbfc44da

Browse files
committed
Prevent inconsistent use of stats entry for replication slots
Concurrent activity around replication slot creation and drop couldcause a replication slot to use a stats entry it should not have usedwhen created, triggering an assertion failure when retrieving thisinconsistent entry from the dshash table used by the stats facility.The issue is that pgstat_drop_replslot() calls pgstat_drop_entry()without checking the result. If pgstat_drop_entry() cannot free theentry related to the object dropped, pgstat_request_entry_refs_gc()should be called. AtEOXact_PgStat_DroppedStats() and surroundingroutines dropping stats entries already do that.This is documented in pgstat_internal.h, but let's add a comment at thetop of pgstat_drop_entry() as that can be easy to miss.Reported-by: Alexander LakhinAuthor: Floris Van NeeAnalyzed-by: Andres FreundDiscussion:https://postgr.es/m/17947-b9554521ad963c9c@postgresql.orgBackpatch-through: 15
1 parentbb84254 commitbfc44da

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,9 @@ pgstat_acquire_replslot(ReplicationSlot *slot)
153153
void
154154
pgstat_drop_replslot(ReplicationSlot*slot)
155155
{
156-
pgstat_drop_entry(PGSTAT_KIND_REPLSLOT,InvalidOid,
157-
ReplicationSlotIndex(slot));
156+
if (!pgstat_drop_entry(PGSTAT_KIND_REPLSLOT,InvalidOid,
157+
ReplicationSlotIndex(slot)))
158+
pgstat_request_entry_refs_gc();
158159
}
159160

160161
/*

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,17 @@ pgstat_drop_database_and_contents(Oid dboid)
850850
pgstat_request_entry_refs_gc();
851851
}
852852

853+
/*
854+
* Drop a single stats entry.
855+
*
856+
* This routine returns false if the stats entry of the dropped object could
857+
* not be freed, true otherwise.
858+
*
859+
* The callers of this function should call pgstat_request_entry_refs_gc()
860+
* if the stats entry could not be freed, to ensure that this entry's memory
861+
* can be reclaimed later by a different backend calling
862+
* pgstat_gc_entry_refs().
863+
*/
853864
bool
854865
pgstat_drop_entry(PgStat_Kindkind,Oiddboid,Oidobjoid)
855866
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp