weaviate/weaviate · error
dist between %d and %d
Error message
dist between %d and %d
What it means
Wraps a distance-calculation error between the inserted node and one of its neighbors inside connectNeighborAtLevel. Deleted objects (storobj.ErrNotFound) are handled gracefully; any other distancer error is wrapped here and aborts neighbor connection for that node.
Source
Thrown at adapters/repos/db/vector/hnsw/neighbor_connections.go:366
// we can simply append
// updatedConnections = append(currentConnections, n.node.id)
neighbor.appendConnectionAtLevelNoLock(level, n.node.id, maximumConnections)
if err := n.graph.commitLog.AddLinkAtLevel(neighbor.id, level, n.node.id); err != nil {
return err
}
} else {
// we need to run the heuristic
dist, err := n.graph.distBetweenNodes(n.node.id, neighborID)
if err != nil {
var e storobj.ErrNotFound
if errors.As(err, &e) {
n.graph.handleDeletedNode(e.DocID, "connectNeighborAtLevel")
// it seems either the node or the neighbor were deleted in the meantime,
// there is nothing we can do now
return nil
}
return errors.Wrapf(err, "dist between %d and %d", n.node.id, neighborID)
}
candidates := priorityqueue.NewMax[any](len(currentConnections) + 1)
candidates.Insert(n.node.id, dist)
for _, existingConnection := range currentConnections {
dist, err := n.graph.distBetweenNodes(existingConnection, neighborID)
if err != nil {
var e storobj.ErrNotFound
if errors.As(err, &e) {
n.graph.handleDeletedNode(e.DocID, "connectNeighborAtLevel")
// was deleted in the meantime
continue
}
return errors.Wrapf(err, "dist between %d and %d", existingConnection, neighborID)
}
candidates.Insert(existingConnection, dist)View on GitHub (pinned to 75aa4b6d11)
Solutions
- Identify the object IDs from the wrapped error and validate/repair their vectors (re-export and re-import the affected objects)
- Check for NaN/Inf values in vectors supplied at import time and fix client-side normalization
- Restore the shard from backup if vectors on disk are corrupt
- Keep weaviate upgraded — several distancer error-handling fixes landed in later versions
Defensive patterns
Strategy: validation
Validate before calling
// validate vectors client-side before batch import
for _, o := range objects {
if len(o.Vector) != expectedDim { return fmt.Errorf("dim mismatch for %s", o.ID) }
for _, x := range o.Vector { if math.IsNaN(float64(x)) || math.IsInf(float64(x), 0) { return fmt.Errorf("non-finite vector for %s", o.ID) } }
} Type guard
func validVector(v []float32, dim int) bool {
if len(v) != dim { return false }
for _, x := range v { if math.IsNaN(float64(x)) || math.IsInf(float64(x), 0) { return false } }
return true
} Prevention
- Validate vector dimensionality and finiteness before import
- Match the configured vectorizer/distance metric to the data
- Back up shards; restore if disk-level corruption is detected
- Upgrade weaviate for improved distancer error handling
When it happens
Trigger: connectNeighborAtLevel calls the distancer for (node, neighborID) and gets a non-ErrNotFound error — e.g. the neighbor object exists but its vector is unreadable/corrupt, or a quantization/PQ codec errors on the stored bytes.
Common situations: Corrupted or truncated vector data after an unclean shutdown; wrong distance metric configured for imported vectors (NaN/Inf vectors); module-serialized vectors failing to deserialize.
Related errors
- calculate distance of current last result
- calculate distance between candidate and query
- calculated distance between worst result and query
- index is not hnsw
- at least one iterator required
AI-assisted analysis of weaviate/weaviate@75aa4b6d11 (2026-09-04).
Data as JSON: /api/errors/dd5bb46adeded6c5.
Report an issue: GitHub.