mirror of
https://github.com/pgvector/pgvector.git
synced 2026-06-30 09:41:15 +08:00
Revert "Added version to reduce stale reads and writes and prepare for optimistic locking"
This reverts commit ef1209eaf4.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user