pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
[pgvector/pgvector] issue #1068: [BUG] Iterative HNSW scan during vacuum fails with `ERROR: cannot load deleted element`
3+ messages / 2 participants
[nested] [flat]

* [pgvector/pgvector] issue #1068: [BUG] Iterative HNSW scan during vacuum fails with `ERROR: cannot load deleted element`
@ 2026-11-18 06:40  "Wwwing301 (@Wwwing301)" <noreply+Wwwing301@github.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Wwwing301 (@Wwwing301) @ 2026-11-18 06:40 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

**Describe the bug**
On pgvector 0.8.7, an HNSW iterative scan (`hnsw.iterative_scan = strict_order`) running concurrently with `VACUUM` on the same index fails with `ERROR: cannot load deleted element`. During vacuum, deleted element tuples are removed before being repaired, so a resumed iterative scan can still visit one that vacuum is about to delete. The upstream fix `2f7507eb7aab` (2026-10-31, "Fixed possible error with iterative index scans during HNSW vacuuming") adds the missing repair path in `src/hnswvacuum.c`; 0.8.7 predates it and does not contain the fix.

**Environment**
- pgvector 0.8.7, docker image `pgvector/pgvector:pg17` (PostgreSQL 17.12 Debian), Linux x86_64
- Date: 2026-11-17; GUC `hnsw.iterative_scan = strict_order`; table autovacuum disabled
- Version check: 0.8.7 lacks `2f7507eb7aab` — `src/hnswvacuum.c` has no `RepairDeleting`/`RepairDeletingNeighbors`

**To Reproduce**
1. Setup, mirroring upstream `test/t/046_hnsw_vacuum_scan.pl`:
```sql
CREATE TABLE tst2 (i serial, v vector(3));
ALTER TABLE tst2 SET (autovacuum_enabled = false);
INSERT INTO tst2 (v) SELECT ARRAY[random(),random(),random()] FROM generate_series(1,1000);
CREATE INDEX ON tst2 USING hnsw (v vector_l2_ops);
DELETE FROM tst2;
```
2. `sel.sql`:
```sql
SET hnsw.iterative_scan = strict_order;
SELECT i FROM tst2 ORDER BY v <-> '[0,0,0]' LIMIT 10;
```
   `vac.sql`: `VACUUM tst2;`
3. Run five concurrent clients, 1000 transactions each, one vacuum per 1000 selects:
```
pgbench -U postgres -d postgres -n --no-vacuum -c 5 -t 1000 \
        -f sel.sql@1000 -f vac.sql@1
```
4. Observe the `pgbench` exit status and the server log.

**Expected behavior**
Iterative scans and vacuum must run concurrently without error: each scan returns up to 10 rows (here none — the table is empty after `DELETE`), `VACUUM` completes, and `pgbench` processes all 5000 transactions; a scan must never abort the client with an internal error.

**Actual behavior**
`pgbench` aborted mid-run — "number of transactions actually processed: 1984/5000", "Run was aborted; the above results are incomplete." The server log shows four errors within 1 ms from distinct backends (PIDs 17304-17307) at 08:33:05 UTC: `ERROR: cannot load deleted element`. Failures are non-deterministic and vanish once vacuum finishes, so retries mask the defect.

^ permalink  raw  [nested|flat] 3+ messages in thread

* Re: [pgvector/pgvector] issue #1068: [BUG] Iterative HNSW scan during vacuum fails with `ERROR: cannot load deleted element`
@ 2026-11-18 06:44  "ankane (@ankane)" <noreply+ankane@github.com>
  1 sibling, 0 replies; 3+ messages in thread

From: ankane (@ankane) @ 2026-11-18 06:44 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hi @Wwwing301, as you note, this is already fixed and will be part of the next release.

^ permalink  raw  [nested|flat] 3+ messages in thread

* Re: [pgvector/pgvector] issue #1068: [BUG] Iterative HNSW scan during vacuum fails with `ERROR: cannot load deleted element`
@ 2026-11-18 06:44  "ankane (@ankane)" <noreply+ankane@github.com>
  1 sibling, 0 replies; 3+ messages in thread

From: ankane (@ankane) @ 2026-11-18 06:44 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@ankane closed this.

^ permalink  raw  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2026-11-18 06:44 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-18 06:40 [pgvector/pgvector] issue #1068: [BUG] Iterative HNSW scan during vacuum fails with `ERROR: cannot load deleted element` "Wwwing301 (@Wwwing301)" <noreply+Wwwing301@github.com>
2026-11-18 06:44 ` "ankane (@ankane)" <noreply+ankane@github.com>
2026-11-18 06:44 ` "ankane (@ankane)" <noreply+ankane@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