pgvector.git / summary / log / commit / refs
commit 564a3d45fc20ac66037f661a3fa340a3bcbb19ca
Author: Andrew Kane <andrew@ankane.org>
Date: Thu Oct 05 03:14:50 2023 +0000
Added check for MVCC-compliant snapshot for HNSW index scans - closes #281
CHANGELOG.md | 1 +
src/hnswscan.c | 14 +++++---------
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 00c8be15..55f9b857 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,6 @@
## 0.5.1 (unreleased)
+- Added check for MVCC-compliant snapshot for HNSW index scans
- Improved performance of index scans for IVFFlat after updates and deletes
## 0.5.0 (2023-08-28)
diff --git a/src/hnswscan.c b/src/hnswscan.c
index d391a10d..7cf2bf0d 100644
--- a/src/hnswscan.c
+++ b/src/hnswscan.c
@@ -160,6 +160,11 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
if (scan->orderByData == NULL)
elog(ERROR, "cannot scan hnsw index without order");
+ /* Requires MVCC-compliant snapshot as not able to maintain a pin */
+ /* https://www.postgresql.org/docs/current/index-locking.html */
+ if (!IsMVCCSnapshot(scan->xs_snapshot))
+ elog(ERROR, "non-MVCC snapshots are not supported with hnsw");
+
/* Get scan value */
value = GetScanValue(scan);
@@ -201,15 +206,6 @@ hnswgettuple(IndexScanDesc scan, ScanDirection dir)
scan->xs_ctup.t_self = *heaptid;
#endif
- /*
- * Typically, an index scan must maintain a pin on the index page
- * holding the item last returned by amgettuple. However, this is not
- * needed with the current vacuum strategy, which ensures scans do not
- * visit tuples in danger of being marked as deleted.
- *
- * https://www.postgresql.org/docs/current/index-locking.html
- */
-
scan->xs_recheckorderby = false;
return true;
}
[parent: 8d7abb659070]