pgvector.git / summary / log / commit / refs
commit a62c045c937cd5d23d4649a7b59cde9da4fbf88e
Author: Andrew Kane <andrew@ankane.org>
Date: Sat Aug 19 19:19:42 2023 +0000
Update metapage if needed for HNSW vacuum
src/hnswvacuum.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/hnswvacuum.c b/src/hnswvacuum.c
index f493bd27..60e2410d 100644
--- a/src/hnswvacuum.c
+++ b/src/hnswvacuum.c
@@ -368,13 +368,24 @@ RepairGraph(HnswVacuumState * vacuumstate)
foreach(lc2, elements)
{
HnswElement element = (HnswElement) lfirst(lc2);
+ HnswElement entryPoint;
/* Check if any neighbors point to deleted values */
if (!NeedsUpdated(vacuumstate, element))
continue;
/* Refresh entry point for each element */
- RepairGraphElement(vacuumstate, element, HnswGetEntryPoint(index));
+ entryPoint = HnswGetEntryPoint(index);
+
+ /* Repair connections */
+ RepairGraphElement(vacuumstate, element, entryPoint);
+
+ /*
+ * Update metapage if needed. Should only happen if entry point
+ * was replaced and highest point was outdated.
+ */
+ if (entryPoint == NULL || element->level > entryPoint->level)
+ HnswUpdateMetaPage(index, HNSW_UPDATE_ENTRY_GREATER, element, InvalidBlockNumber, MAIN_FORKNUM);
}
/* Reset memory context */
[parent: 651e4343c129]