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

Commit0557e17

Browse files
committed
Ignore invalidated slots while computing oldest catalog Xmin
Once a logical slot has acquired a catalog_xmin, it doesn't let go ofit, even when invalidated by exceeding the max_slot_wal_keep_size, whichmeans that dead catalog tuples are not removed by vacuum anymore sincethe point is invalidated, until the slot is dropped. This could becatastrophic if catalog churn is high.Change the computation of Xmin to ignore invalidated slots,to prevent dead rows from accumulating.Backpatch to 13, where slot invalidation appeared.Author: Sirisha Chamarthi <sirichamarthi22@gmail.com>Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>Discussion:https://postgr.es/m/CAKrAKeUEDeqquN9vwzNeG-CN8wuVsfRYbeOUV9qKO_RHok=j+g@mail.gmail.com
1 parent92daeca commit0557e17

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

‎src/backend/replication/slot.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,15 +847,22 @@ ReplicationSlotsComputeRequiredXmin(bool already_locked)
847847
ReplicationSlot*s=&ReplicationSlotCtl->replication_slots[i];
848848
TransactionIdeffective_xmin;
849849
TransactionIdeffective_catalog_xmin;
850+
boolinvalidated;
850851

851852
if (!s->in_use)
852853
continue;
853854

854855
SpinLockAcquire(&s->mutex);
855856
effective_xmin=s->effective_xmin;
856857
effective_catalog_xmin=s->effective_catalog_xmin;
858+
invalidated= (!XLogRecPtrIsInvalid(s->data.invalidated_at)&&
859+
XLogRecPtrIsInvalid(s->data.restart_lsn));
857860
SpinLockRelease(&s->mutex);
858861

862+
/* invalidated slots need not apply */
863+
if (invalidated)
864+
continue;
865+
859866
/* check the data xmin */
860867
if (TransactionIdIsValid(effective_xmin)&&
861868
(!TransactionIdIsValid(agg_xmin)||

‎src/backend/storage/ipc/procarray.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3901,6 +3901,9 @@ ProcArraySetReplicationSlotXmin(TransactionId xmin, TransactionId catalog_xmin,
39013901

39023902
if (!already_locked)
39033903
LWLockRelease(ProcArrayLock);
3904+
3905+
elog(DEBUG1,"xmin required by slots: data %u, catalog %u",
3906+
xmin,catalog_xmin);
39043907
}
39053908

39063909
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp