diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c index 08d7201f19..3b8865331a 100644 --- a/src/backend/access/nbtree/nbtutils.c +++ b/src/backend/access/nbtree/nbtutils.c @@ -1858,7 +1858,17 @@ _bt_killitems(IndexScanDesc scan) else if (ItemPointerEquals(&ituple->t_tid, &kitem->heapTid)) killtuple = true; - if (killtuple) + /* + * Mark index item as dead, if not yet. Since killing dead + * index items can be performed while holding a buffer lock + * in share mode, it's possible that concurrent processes + * attempt to kill the same index item simultaneously, which + * in turn leads to write multiple full-page writes for hintbit. + * Checking if the index item is already marked as dead will + * help with reducing the likelihood of having multiple + * full-page writes. + */ + if (killtuple && !ItemIdIsDead(iid)) { /* found the item/all posting list items */ ItemIdMarkDead(iid);