From 8d7abb659070259e78f5c0974dde26c9e1cda8d3 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 26 Sep 2023 23:00:14 -0700 Subject: [PATCH] Revert "Fixed locking for index scans for HNSW - #256" This reverts commit d032726976132f3f40b4931ed490068b2182278d. --- CHANGELOG.md | 1 - src/hnswscan.c | 18 +++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index af75e5b..00c8be1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,6 @@ ## 0.5.1 (unreleased) - Improved performance of index scans for IVFFlat after updates and deletes -- Fixed locking for index scans for HNSW ## 0.5.0 (2023-08-28) diff --git a/src/hnswscan.c b/src/hnswscan.c index 5543cb8..d391a10 100644 --- a/src/hnswscan.c +++ b/src/hnswscan.c @@ -113,12 +113,6 @@ hnswbeginscan(Relation index, int nkeys, int norderbys) scan->opaque = so; - /* - * 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); - return scan; } @@ -169,8 +163,17 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir) /* Get scan value */ value = GetScanValue(scan); + /* + * 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); + /* Release shared lock */ + UnlockPage(scan->indexRelation, HNSW_SCAN_LOCK, ShareLock); + so->first = false; } @@ -223,9 +226,6 @@ hnswendscan(IndexScanDesc scan) { HnswScanOpaque so = (HnswScanOpaque) scan->opaque; - /* Release shared lock */ - UnlockPage(scan->indexRelation, HNSW_SCAN_LOCK, ShareLock); - MemoryContextDelete(so->tmpCtx); pfree(so);