pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: ankane (@ankane) <noreply+ankane@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] PR #282: Hnsw iterator
Date: Tue, 24 Sep 2024 17:38:06 +0000
Message-ID: <gh-pgvector-pgvector-282-c2371913453@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-282@github.com>
References: <gh-pgvector-pgvector-282@github.com>

Hi @knizhnik, two things that can happen with the approach in this PR related to vacuuming are:

1. An element can be replaced between reading the element tuple and reading the neighbor tuple, giving an incorrect list of neighbors.
2. When reading neighbors, one of the elements may be replaced between reading the neighbor tuple and reading the element tuple, giving an incorrect element.

#678 addresses this by:

1. Adding a version to each element
2. Using `HNSW_SCAN_LOCK` (which prevents both 1 and 2 in the non-iterative approach). This ensures vacuuming waits for current scan iterations to complete before marking elements as deleted (at which point an element can be immediately replaced). Iterations that start after vacuuming begins marking elements as deleted won't see any of those elements in neighbor tuples, avoiding this issue. Another approach (requiring a bit more space) would be to save the element version of each neighbor in the neighbor tuple.

view thread (33+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-282-c2371913453@github.com>
Permalink:  ../gh-pgvector-pgvector-282-c2371913453@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox