Wrong-dimension Add leaves a visible HNSW ghost node
Author: leemeiiCreated Sep 8, 2026Updated Sep 15, 2026
Labelsbugcommunity
How to reproduce this bug?
#!/usr/bin/env python3
import os
import subprocess
import sys
from pathlib import Path
src = Path(os.environ.get("WEAVIATE_SRC", ".")).resolve()
pkg = src / "adapters/repos/db/vector/hnsw"
test = pkg / "zz_wrong_dimension_ghost_repro_test.go"
test.write_text(r'''
package hnsw
import (
"context"
"testing"
"github.com/stretchr/testify/require"
)
func TestWrongDimensionGhostNode(t *testing.T) {
index := testHNSW(t)
defer index.Shutdown(context.Background())
require.NoError(t, index.AddBatch(context.Background(),
[]uint64{1, 2},
[][]float32{{1, 0, 0, 0}, {0, 1, 0, 0}},
))
require.Error(t, index.Add(context.Background(), 3,
[]float32{0, 0, 1}))
if index.ContainsDoc(3) {
t.Fatalf("ghost node detected: ContainsDoc(3) == true")
}
}
''')
try:
p = subprocess.run(
[
"go", "test",
"./adapters/repos/db/vector/hnsw",
"-run", "^TestWrongDimensionGhostNode$",
"-count=1",
"-v",
],
cwd=src,
text=True,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
print(p.stdout)
if "ghost node detected" in p.stdout:
print("REPRODUCED: failed Add left document 3 visible")
sys.exit(0)
sys.exit(p.returncode or 1)
finally:
test.unlink(missing_ok=True)What is the expected behavior?
The wrong-dimension Add should return an error, and the failed document must not remain visible.
Expected:
- Add returns an error.
- ContainsDoc(3) returns false.
- The Go test passes.
go testexits with code 0.- The Python reproducer must not print
ghost node detected.
What is the actual behavior?
The wrong-dimension Add returns an error, but document 3 remains visible.
Actual:
- Add returns an error.
- ContainsDoc(3) returns true.
- The Go test fails with:
ghost node detected: ContainsDoc(3) == true go testexits with a non-zero status.- The Python reproducer detects this failed assertion and prints:
REPRODUCED: failed Add left document 3 visible - The Python reproducer exits with code 0 to indicate that the bug was successfully reproduced.
Supporting information
No response
Server Version
1.40.0-dev
Weaviate Setup
Single Node
Nodes count
No response
Code of Conduct
- I have read and agree to the Weaviate's Contributor Guide and Code of Conduct
Source: weaviate/weaviate