{"record":{"id":"1bcc29bbd810ef80","repo":"weaviate/weaviate","slug":"bucket-q-w-1bcc29","errorCode":null,"errorMessage":"bucket %q: %w","messagePattern":"bucket %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/repos/db/sorter/inverted_sorter.go","lineNumber":131,"sourceCode":"\tnesting int,\n) ([]uint64, error) {\n\tif len(sort) < 1 {\n\t\t// this should never happen, the query planner should already have chosen\n\t\t// another strategy\n\t\treturn nil, fmt.Errorf(\"no sort clause provided, expected at least one sort clause\")\n\t}\n\n\tpropNames, orders, err := extractPropNamesAndOrders(sort)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// pinned for the whole sort: the bucket backs every cursor opened below,\n\t// and an unpinned pointer can be shut down between the lookup and the scan\n\tbucketName := helpers.BucketFromPropNameLSM(propNames[0])\n\tbucket, release := is.store.AcquireBucketForRead(bucketName)\n\tif bucket == nil {\n\t\treturn nil, fmt.Errorf(\"bucket %q: %w\", bucketName, lsmkv.ErrBucketNotFound)\n\t}\n\tdefer release()\n\tif bucket.Strategy() != lsmkv.StrategyRoaringSet {\n\t\t// this should never happen, the query planner should already have chosen\n\t\t// another strategy\n\t\treturn nil, fmt.Errorf(\"expected roaring set bucket for property %s, got %s\",\n\t\t\tpropNames[0], bucket.Strategy())\n\t}\n\n\tswitch orders[0] {\n\tcase \"asc\":\n\t\treturn is.sortRoaringSetASC(ctx, bucket, limit, sort, ids, nesting)\n\tcase \"desc\":\n\t\treturn is.sortRoaringSetDESC(ctx, bucket, limit, sort, ids, nesting)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported sort order %s\", orders[0])\n\t}\n}","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/repos/db/sorter/inverted_sorter.go#L113-L149","documentation":"During inverted-index sorting, the sorter needs the roaring-set bucket backing the first sort property. It acquires the bucket for read; if the store has no such bucket (property has no inverted index bucket, or store not open) it returns this error wrapping lsmkv.ErrBucketNotFound. The comment notes buckets backing open cursors must be pinned for the whole sort, so this lookup failing means sorting on that property cannot proceed at all.","triggerScenarios":"Sort on property whose LSM bucket (helpers.BucketFromPropNameLSM) does not exist in the shard store — property name mismatch, property created before/after bucket creation, or AcquireBucketForRead returning nil because the bucket was dropped or the store is closed. Also when AcquireBucketForRead returns nil mid-shutdown between planning and execution.","commonSituations":"Sorting on a property that is not indexed/inverted-indexable (skipped indexing: indexFilterable/indexSearchable=false), schema migration where old shards lack the bucket, races with shard close during tenant offload, typo'd property name in GraphQL sort clause (usually caught by planner earlier).","solutions":["Verify the sort property exists and has filtering/sorting enabled (indexFilterable not disabled) in the collection schema.","Check that the shard is open and the node is not shutting down; retry the query if a shutdown/offload race is suspected.","If it happens after a version upgrade or reindex, rebuild the shard index so property buckets are created.","Inspect the wrapped lsmkv.ErrBucketNotFound in logs to confirm which bucket name is missing, and compare against the shard's actual buckets."],"exampleFix":"// before\nbucket, release := is.store.AcquireBucketForRead(bucketName)\nif bucket == nil {\n\treturn nil, fmt.Errorf(\"bucket %q: %w\", bucketName, lsmkv.ErrBucketNotFound)\n}\n// after — caller-side guard\nif errors.Is(err, lsmkv.ErrBucketNotFound) {\n\treturn nil, status.NewStatusError(...)\n\t// or fall back to unsorted / plan a different strategy\n}","handlingStrategy":"fallback","validationCode":"bucket, _ := store.AcquireBucketForRead(helpers.BucketFromPropNameLSM(prop))\nif bucket == nil { return errors.New(\"sort property has no inverted index bucket\") }","typeGuard":"func bucketExists(store *lsmkv.Store, prop string) bool {\n\tb, _ := store.AcquireBucketForRead(helpers.BucketFromPropNameLSM(prop))\n\tif b == nil { return false }\n\tdefer b.Release()\n\treturn b.Strategy() == lsmkv.StrategyRoaringSet\n}","tryCatchPattern":"if err != nil {\n\tif errors.Is(err, lsmkv.ErrBucketNotFound) {\n\t\treturn fallbackBruteForceSort(ctx, ids, sort) // fall back to objects-bucket sort\n\t}\n\treturn err\n}","preventionTips":["Enable indexFilterable on properties used in sort clauses","Verify the query planner only routes properties with roaring-set buckets to the inverted sorter","Watch for shard shutdown races — re-check bucket availability before deep scans","Reindex shards after upgrades that change bucket naming"],"tags":["go","lsmkv","sorting","inverted-index"],"backgroundTag":"bucket-not-found","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"}