{"record":{"id":"3ceda2d9054252a8","repo":"dgraph-io/dgraph","slug":"error-fetching-posting-list","errorCode":null,"errorMessage":"error fetching posting list","messagePattern":"error fetching posting list","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"tok/hnsw/helper.go","lineNumber":51,"sourceCode":"\tvisitedVectorsLevel  = \"visited_vectors_level_\"\n\tdistanceComputations = \"vector_distance_computations\"\n\tsearchTime           = \"vector_search_time\"\n\tVecEntry             = \"__vector_entry\"\n\tVecDead              = \"__vector_dead\"\n\tVectorIndexMaxLevels = 5\n\tEfConstruction       = 16\n\tEfSearch             = 12\n\t// ByteData indicates the key stores data.\n\tByteData = byte(0x00)\n\t// DefaultPrefix is the prefix used for data, index and reverse keys so that relative\n\tDefaultPrefix = byte(0x00)\n\t// NsSeparator is the separator between the namespace and attribute.\n\tNsSeparator = \"-\"\n)\n\nvar (\n\terrNilVector           = errors.New(\"nil vector returned\")\n\terrFetchingPostingList = errors.New(\"error fetching posting list\")\n)\n\ntype SearchResult struct {\n\tnnUids        []uint64\n\ttraversalPath []uint64\n\textraMetrics  map[string]uint64\n}\n\nfunc (s *SearchResult) GetNnUids() []uint64 {\n\treturn s.nnUids\n}\n\nfunc (s *SearchResult) GetTraversalPath() []uint64 {\n\treturn s.traversalPath\n}\n\nfunc (s *SearchResult) GetExtraMetrics() map[string]uint64 {\n\treturn s.extraMetrics","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/dgraph-io/dgraph/blob/759e242be62c91f8d084da06ad0c8d21256d9c07/tok/hnsw/helper.go#L33-L69","documentation":"errFetchingPostingList is a sentinel error returned by HNSW helper functions (getDataFromKeyWithCacheType, populateEdgeDataFromKeyWithCacheType, getVecFromUid, removeDeadNodes, SearchWithUid/Options) when reading the posting list for a key from Badger fails (the inner error is typically wrapped/logged). It means the vector-index layer could not fetch the underlying postings data for a UID or key.","triggerScenarios":"Vector search (SearchWithUid, SearchWithUidAndOptions) or index maintenance (removeDeadNodes) hitting a posting-list read error: DB I/O failure, key corruption, or key not readable at the given read timestamp.","commonSituations":"Badger disk/IO issues or corrupted SST files after crash; querying with a readTs below/at a problematic timestamp; restore/migration leaving inconsistent postings for vector predicates.","solutions":["Inspect the underlying Badger error logged alongside this sentinel to find the root cause","Retry the query; transient IO/lock issues may resolve","Run Badger integrity checks / backup-restore tooling if corruption is suspected","Rebuild the vector index for the predicate if postings remain unreadable"],"exampleFix":"// before\nres, err := hnsw.SearchWithUid(ctx, index, uid, opts) // errFetchingPostingList\n// after\nif errors.Is(err, tok.ErrFetchingPostingList) {\n    log.Warnf(\"posting list read failed for uid %d, retrying\", uid)\n    res, err = hnsw.SearchWithUid(ctx, index, uid, opts)\n}","handlingStrategy":"retry","validationCode":"// health check before vector queries\nif err := dbHealthCheck(ctx); err != nil {\n    return fmt.Errorf(\"postings store unhealthy: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"res, err := hnsw.SearchWithUid(ctx, idx, uid, opts)\nif err != nil {\n    if errors.Is(err, errFetchingPostingList) {\n        return backoffRetry(ctx, 3, func() error {\n            r, e := hnsw.SearchWithUid(ctx, idx, uid, opts); res = r; return e\n        })\n    }\n    return err\n}","preventionTips":["Monitor Badger disk health and IO errors; check logs for the wrapped root cause","Run integrity/backup tooling after crashes or restores","Retry transient read failures with backoff before surfacing to users","Rebuild vector indexes whose postings stay unreadable"],"tags":["dgraph","vector-index","hnsw","storage","posting-list"],"backgroundTag":"posting-list-fetch-failed","analyzedSha":"759e242be62c91f8d084da06ad0c8d21256d9c07","analyzedAt":"2026-09-01T14:42:12.034Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}