{"record":{"id":"f6d52d1b470625b6","repo":"weaviate/weaviate","slug":"failed-to-search-for-nearest-centroid-for-posting","errorCode":null,"errorMessage":"failed to search for nearest centroid for posting %d","messagePattern":"failed to search for nearest centroid for posting (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/repos/db/vector/hfresh/merge.go","lineNumber":117,"sourceCode":"\t\tvectorSet[v.ID()] = struct{}{}\n\t}\n\n\t// get posting centroid\n\toldCentroid, err := h.Centroids.Get(postingID)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"failed to get centroid for posting %d\", postingID)\n\t}\n\n\tif oldCentroid == nil {\n\t\th.logger.WithField(\"postingID\", postingID).\n\t\t\tDebug(\"posting centroid not found, skipping merge operation\")\n\t\treturn nil\n\t}\n\n\t// search for the closest centroids\n\tnearest, err := h.Centroids.Search(oldCentroid.Uncompressed, h.config.InternalPostingCandidates, nil)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"failed to search for nearest centroid for posting %d\", postingID)\n\t}\n\n\tif nearest.Len() <= 1 {\n\t\th.logger.WithField(\"postingID\", postingID).\n\t\t\tDebug(\"no candidates found for merge operation, skipping\")\n\n\t\t// persist the gc'ed posting\n\t\terr = h.PostingStore.Put(ctx, postingID, newPosting)\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"failed to put filtered posting %d\", postingID)\n\t\t}\n\t\t// update the size of the posting after successful Persist\n\t\terr = h.setPostingVectorIDs(ctx, postingID, newPosting)\n\t\tif err != nil {\n\t\t\treturn errors.Wrapf(err, \"failed to set size of posting %d to %d\", postingID, prevLen)\n\t\t}\n\n\t\treturn nil","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/repos/db/vector/hfresh/merge.go#L99-L135","documentation":"To find merge candidates, doMerge searches the centroid index for the closest InternalPostingCandidates centroids to this posting's centroid. This error wraps a failure of that nearest-neighbor search over centroids. Without candidate centroids the merge cannot proceed and is aborted for this posting.","triggerScenarios":"h.Centroids.Search(oldCentroid.Uncompressed, h.config.InternalPostingCandidates, nil) errors — failure inside the centroid search structure (I/O, context cancellation, corrupt search state, malformed centroid vector).","commonSituations":"Corrupted or partially flushed centroid index after crash; context deadline exceeded on large centroid sets under load; misconfigured InternalPostingCandidates combined with storage failures; disk I/O problems on the shard.","solutions":["Inspect the wrapped cause; retry the merge if it was transient (context timeout, I/O hiccup).","Validate shard integrity / run recovery if the centroid index fails searches repeatedly.","Check disk health and context timeout settings for background maintenance.","If reproducible after restart, rebuild the affected shard's index."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"if err := ctx.Err(); err != nil {\n    return err\n}","typeGuard":null,"tryCatchPattern":"if err := merge.Execute(ctx); err != nil {\n    if strings.Contains(err.Error(), \"failed to search for nearest centroid\") {\n        if errors.Is(err, context.DeadlineExceeded) {\n            return retryWithBackoff(err)\n        }\n        // non-transient: inspect unwrapped cause for corruption\n    }\n    return err\n}","preventionTips":["Size context deadlines for centroid searches over the full centroid set.","Validate InternalPostingCandidates config against index size.","Run post-crash integrity checks on the centroid index.","Rebuild the shard index if centroid searches persistently fail after restart."],"tags":["hfresh","centroid","search","merge"],"backgroundTag":"centroid-search-failed","analyzedSha":"75aa4b6d11f8818305aafd4440b4e32794f7ca04","analyzedAt":"2026-09-04T14:58:20.392Z","contentChangedAt":"2026-09-04T14:58:20.392Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}