Improved locking code [skip ci]

This commit is contained in:
Andrew Kane
2023-08-21 15:42:59 -07:00
parent 3f3b3ca8e3
commit 0e1de45463
4 changed files with 22 additions and 10 deletions

View File

@@ -145,9 +145,17 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
HnswNormValue(so->normprocinfo, so->collation, &value, NULL);
}
LockPage(scan->indexRelation, HNSW_HEAD_BLKNO, ShareLock);
/*
* Get a shared lock. This allows vacuum to ensure no in-flight scans
* before marking tuples as deleted.
*/
LockPage(scan->indexRelation, HNSW_SCAN_LOCK, ShareLock);
so->w = GetScanItems(scan, value);
UnlockPage(scan->indexRelation, HNSW_HEAD_BLKNO, ShareLock);
/* Release shared lock */
UnlockPage(scan->indexRelation, HNSW_SCAN_LOCK, ShareLock);
so->first = false;
}