{"record":{"id":"1819a9a96d29cc61","repo":"weaviate/weaviate","slug":"process-descending-window-w","errorCode":null,"errorMessage":"process descending window: %w","messagePattern":"process descending window: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/repos/db/sorter/inverted_sorter.go","lineNumber":238,"sourceCode":"\tstartTime := time.Now()\n\thasMoreNesting := len(sort) > 1\n\tqks := is.quantileKeysForDescSort(ctx, limit, ids, bucket, nesting)\n\n\tfoundIDs := make([]uint64, 0, limit)\n\tseeksRequired := 0\n\tidCountBeforeCutoff := 0\n\trowsEvaluated := 0\n\twhenComplete := is.annotateDESC(ctx, nesting, len(qks), startTime, &rowsEvaluated, &idCountBeforeCutoff, &seeksRequired)\n\tdefer whenComplete()\n\n\tfor qkIndex := len(qks) - 1; qkIndex >= 0; qkIndex-- {\n\t\tseeksRequired++\n\t\tstartKey, endKey := cursorKeysForDESCWindow(qks, qkIndex)\n\n\t\tidsInWindow, rowsInWindow, err := is.processDESCWindow(ctx, bucket,\n\t\t\tstartKey, endKey, ids, limit, nesting, hasMoreNesting, sort)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"process descending window: %w\", err)\n\t\t}\n\n\t\trowsEvaluated += rowsInWindow\n\n\t\t// prepend ids from window, the full list will be reversed at the end\n\t\tfoundIDs = append(idsInWindow, foundIDs...)\n\t\tif len(foundIDs) >= limit {\n\t\t\t// we have enough ids, no need to continue\n\t\t\tbreak\n\t\t}\n\t}\n\n\t// the inverted index is in ASC order meaning our best matches are at the\n\t// very end of the slice, we need to reverse it before applying the cut-off\n\tslices.Reverse(foundIDs)\n\tidCountBeforeCutoff = len(foundIDs)\n\tif len(foundIDs) > limit {\n\t\tfoundIDs = foundIDs[:limit]","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/repos/db/sorter/inverted_sorter.go#L220-L256","documentation":"In a descending sort on a roaring-set bucket, results are produced in windows of quantile keys. When processing one such window (processDESCWindow) fails, this error wraps and labels the failure as 'process descending window', preserving the underlying cause (bucket read error, nesting sub-sort failure, etc.).","triggerScenarios":"sortRoaringSetDESC iterating quantile key windows when the underlying bucket cursor read fails, the bucket is closed mid-scan, or a nested sub-sort (startNestedSort) inside the window returns an error.","commonSituations":"Desc-order sort queries racing shard shutdown/offload; disk I/O errors during cursor scans; deep nesting of sorts causing a failure in an inner sortDocIDsWithNesting call; LSM corruption in the property's roaring-set bucket.","solutions":["Read the wrapped (%w) inner error to find the actual cause — I/O, closed bucket, or nested-sort failure.","Retry the query if a transient shutdown/offload race closed the bucket.","Check disk health and LSM segment integrity for the affected shard if errors repeat.","Reduce sort nesting depth or simplify the query (fewer sort criteria) if nested sorts are implicated."],"exampleFix":"// before\nreturn nil, fmt.Errorf(\"process descending window: %w\", err)\n// after — caller distinguishes transient vs persistent\nif errors.Is(err, lsmkv.ErrBucketNotFound) {\n\treturn nil, err // non-retryable, property bucket missing\n}\nreturn nil, fmt.Errorf(\"process descending window: %w\", err) // retryable path","handlingStrategy":"retry","validationCode":"if bucket == nil || bucket.Strategy() != lsmkv.StrategyRoaringSet { return errors.New(\"desc sort requires open roaring-set bucket\") }","typeGuard":null,"tryCatchPattern":"ids, err := sorter.SortDocIDs(ctx, limit, sort, ids)\nif err != nil && errors.Is(err, errDescWindow) && isTransient(err) {\n\tids, err = sorter.SortDocIDs(ctx, limit, sort, ids) // one retry\n}","preventionTips":["Avoid issuing sort queries during maintenance windows (offload, restarts)","Set generous context timeouts for desc sorts on large low-cardinality properties","Monitor LSM I/O errors on shards serving heavy desc-sort traffic","Keep sort nesting shallow to limit cascading window failures"],"tags":["go","sorting","inverted-index","lsmkv"],"backgroundTag":"sort-window-processing-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"}