pgvector.git / summary / log / commit / refs
commit 02f4e0ec8b0acd0401b9b86fb0b8fb967b19b800
Author: Andrew Kane <andrew@ankane.org>
Date: Mon Aug 21 09:47:27 2023 +0000
Revert "Added version to reduce stale reads and writes and prepare for optimistic locking"
This reverts commit ef1209eaf48ba3b5827b4c7e9f198504f089e1af.
src/hnsw.h | 5 ++---
src/hnswinsert.c | 9 +++------
src/hnswutils.c | 6 +-----
src/hnswvacuum.c | 2 --
4 files changed, 6 insertions(+), 16 deletions(-)
diff --git a/src/hnsw.h b/src/hnsw.h
index ae2476fe..7495e405 100644
--- a/src/hnsw.h
+++ b/src/hnsw.h
@@ -85,7 +85,6 @@ typedef struct HnswNeighborArray HnswNeighborArray;
typedef struct HnswElementData
{
List *heaptids;
- uint8 version;
uint8 level;
uint8 deleted;
HnswNeighborArray *neighbors;
@@ -186,9 +185,9 @@ typedef HnswPageOpaqueData * HnswPageOpaque;
typedef struct HnswElementTupleData
{
uint8 type;
- uint8 version;
uint8 level;
uint8 deleted;
+ uint8 unused;
ItemPointerData heaptids[HNSW_HEAPTIDS];
ItemPointerData neighbortid;
uint16 unused2;
@@ -200,7 +199,7 @@ typedef HnswElementTupleData * HnswElementTuple;
typedef struct HnswNeighborTupleData
{
uint8 type;
- uint8 version;
+ uint8 unused;
uint16 count;
ItemPointerData indextids[FLEXIBLE_ARRAY_MEMBER];
} HnswNeighborTupleData;
diff --git a/src/hnswinsert.c b/src/hnswinsert.c
index 19f2feee..f0c3d2ad 100644
--- a/src/hnswinsert.c
+++ b/src/hnswinsert.c
@@ -359,11 +359,8 @@ HnswUpdateNeighborPages(Relation index, FmgrInfo *procinfo, Oid collation, HnswE
/* Calculate index for update */
startIdx = (hc->element->level - lc) * m;
- /* TODO Skip when deleting */
- /* TODO Resolve issue with connections from element neighbor tuple */
- if (ntup->version != hc->element->version)
- idx = -1;
- else if (checkExisting && ConnectionExists(e, ntup, startIdx, lm))
+ /* Check for existing connection */
+ if (checkExisting && ConnectionExists(e, ntup, startIdx, lm))
idx = -1;
else if (idx == -2)
{
@@ -477,7 +474,7 @@ HnswAddDuplicate(Relation index, HnswElement element, HnswElement dup)
}
/* Either being deleted or we lost our chance to another backend */
- if (i == 0 || i == HNSW_HEAPTIDS || etup->version != dup->version)
+ if (i == 0 || i == HNSW_HEAPTIDS)
{
GenericXLogAbort(state);
UnlockReleaseBuffer(buf);
diff --git a/src/hnswutils.c b/src/hnswutils.c
index e1bd17c5..4ca1cc25 100644
--- a/src/hnswutils.c
+++ b/src/hnswutils.c
@@ -160,7 +160,6 @@ HnswInitElement(ItemPointer heaptid, int m, double ml, int maxLevel)
element->heaptids = NIL;
HnswAddHeapTid(element, heaptid);
- element->version = 1;
element->level = level;
element->deleted = 0;
@@ -289,7 +288,6 @@ void
HnswSetElementTuple(HnswElementTuple etup, HnswElement element)
{
etup->type = HNSW_ELEMENT_TUPLE_TYPE;
- etup->version = element->version;
etup->level = element->level;
etup->deleted = 0;
for (int i = 0; i < HNSW_HEAPTIDS; i++)
@@ -311,7 +309,6 @@ HnswSetNeighborTuple(HnswNeighborTuple ntup, HnswElement e, int m)
int idx = 0;
ntup->type = HNSW_NEIGHBOR_TUPLE_TYPE;
- ntup->version = e->version;
for (int lc = e->level; lc >= 0; lc--)
{
@@ -351,7 +348,7 @@ LoadNeighborsFromPage(HnswElement element, Relation index, Page page)
HnswInitNeighbors(element, m);
/* Ensure expected neighbors */
- if (ntup->version != element->version || ntup->count != neighborCount)
+ if (ntup->count != neighborCount)
return;
for (int i = 0; i < neighborCount; i++)
@@ -404,7 +401,6 @@ HnswLoadNeighbors(HnswElement element, Relation index)
void
HnswLoadElementFromTuple(HnswElement element, HnswElementTuple etup, bool loadHeaptids, bool loadVec)
{
- element->version = etup->version;
element->level = etup->level;
element->deleted = etup->deleted;
element->neighborPage = ItemPointerGetBlockNumber(&etup->neighbortid);
diff --git a/src/hnswvacuum.c b/src/hnswvacuum.c
index 425e737b..c6dd91bb 100644
--- a/src/hnswvacuum.c
+++ b/src/hnswvacuum.c
@@ -485,12 +485,10 @@ MarkDeleted(HnswVacuumState * vacuumstate)
ntup = (HnswNeighborTuple) PageGetItem(npage, PageGetItemId(npage, neighborOffno));
/* Overwrite element */
- etup->version++;
etup->deleted = 1;
MemSet(&etup->vec.x, 0, etup->vec.dim * sizeof(float));
/* Overwrite neighbors */
- ntup->version = etup->version;
for (int i = 0; i < ntup->count; i++)
ItemPointerSetInvalid(&ntup->indextids[i]);
[parent: 1301706d30e5]