{"record":{"id":"a2ba099e4b1903b1","repo":"weaviate/weaviate","slug":"failed-to-upsert-new-centroid-d","errorCode":null,"errorMessage":"failed to upsert new centroid %d","messagePattern":"failed to upsert new centroid (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/repos/db/vector/hfresh/insert.go","lineNumber":191,"sourceCode":"\ttargets, _, err := h.RNGSelect(v, 0)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// if no postings were found, create a new posting while holding the lock\n\tif targets.Len() == 0 {\n\t\tpostingID, err := h.IDs.Next()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\t// use the vector as the centroid and register it in the SPTAG\n\t\terr = h.Centroids.Insert(postingID, &Centroid{\n\t\t\tUncompressed: v,\n\t\t\tCompressed:   compressed,\n\t\t\tDeleted:      false,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"failed to upsert new centroid %d\", postingID)\n\t\t}\n\t\t// return the new posting ID\n\t\ttargets = NewResultSet(1)\n\t\ttargets.data = append(targets.data, Result{ID: postingID, Distance: 0})\n\t}\n\n\treturn targets, nil\n}\n\n// Append adds a vector to the specified posting.\n// It returns true if the vector was successfully added, false if the posting no longer exists.\n// It is called synchronously during imports but also asynchronously by reassign operations.\nfunc (h *HFresh) append(ctx context.Context, vector Vector, centroidID uint64, reassigned bool) (bool, error) {\n\th.postingLocks.Lock(centroidID)\n\n\t// check if the posting still exists\n\tif !h.Centroids.Exists(centroidID) {\n\t\t// the posting might have been deleted concurrently,","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/repos/db/vector/hfresh/insert.go#L173-L209","documentation":"When the first vector finds no candidate postings, HFresh creates an initial posting: it allocates a posting ID and inserts a Centroid (the vector itself) into the Centroids index. This error wraps a failure of h.Centroids.Insert for the new posting ID.","triggerScenarios":"Inserting into an empty (or fully-deleted) HFresh index via Add/AddMulti where the centroid insert into the Centroids structure fails for the freshly allocated postingID.","commonSituations":"Underlying storage write failure (disk full, I/O error); ID generator (h.IDs.Next) succeeded but centroid store is corrupted or unavailable; concurrent index shutdown.","solutions":["Inspect the wrapped Centroids.Insert error for the storage-level cause.","Check disk space and store health for the shard.","Retry the insert; ensureInitialPosting re-checks for concurrent postings under the lock before creating one.","If the centroid store is corrupted, restore the shard from backup."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := idx.Add(ctx, id, vec); err != nil && strings.Contains(err.Error(), \"failed to upsert new centroid\") {\n    // first-posting creation failed at storage layer; check disk and retry\n}","preventionTips":["Monitor storage health; this fires on the very first insert into an empty index","Avoid dropping the index concurrently with imports","Restore the shard from backup if the centroid store is corrupted"],"tags":["vector-index","hfresh","centroid","persistence"],"backgroundTag":"disk-io-error","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"}