{"record":{"id":"96c47a0661017e6c","repo":"VictoriaMetrics/VictoriaMetrics","slug":"failed-to-search-metricids-w","errorCode":null,"errorMessage":"failed to search metricIDs: %w","messagePattern":"failed to search metricIDs: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/storage/index_db.go","lineNumber":1739,"sourceCode":"\ttfKeyBuf := tagFiltersKeyBufPool.Get()\n\tdefer tagFiltersKeyBufPool.Put(tfKeyBuf)\n\n\ttfKeyBuf.B = marshalTagFiltersKey(tfKeyBuf.B[:0], tfss, tr)\n\tmetricIDs, ok := db.getMetricIDsFromTagFiltersCache(qt, tfKeyBuf.B)\n\tif ok {\n\t\t// Fast path - metricIDs found in the cache\n\t\tif metricIDs.Len() > maxMetrics {\n\t\t\treturn nil, errTooManyTimeseries(maxMetrics)\n\t\t}\n\t\treturn metricIDs, nil\n\t}\n\n\t// Slow path - search for metricIDs in the db\n\tis := db.getIndexSearch(deadline)\n\tmetricIDs, err := is.searchMetricIDs(qt, tfss, tr, maxMetrics)\n\tdb.putIndexSearch(is)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to search metricIDs: %w\", err)\n\t}\n\n\t// Store metricIDs in the cache.\n\tdb.putMetricIDsToTagFiltersCache(qt, metricIDs, tfKeyBuf.B)\n\n\treturn metricIDs, nil\n}\n\nfunc (db *indexDB) wrapError(op string, err error) error {\n\treturn fmt.Errorf(\"failed to %s in indexDB %q: %w\", op, db.name, err)\n}\n\n// SearchTSIDs searches the TSIDs that correspond to filters within the given\n// time range.\n//\n// The returned TSIDs are sorted.\n//\n// The method will fail if the number of found TSIDs exceeds maxMetrics or the","sourceCodeStart":1721,"sourceCodeEnd":1757,"githubUrl":"https://github.com/VictoriaMetrics/VictoriaMetrics/blob/5079fb58f1e8e62113f90c945ad71586c797d770/lib/storage/index_db.go#L1721-L1757","documentation":"This wraps any error from searchMetricIDs on the slow path (tag-filters cache miss) in the tag-filters-to-metricIDs lookup. All underlying index-search errors (I/O, deadline, corruption, limits) surface to the caller wrapped in this message.","triggerScenarios":"Calling SearchMetricIDs (used by all query APIs) when the tag-filters cache misses and the underlying index search fails: deadline exceeded, I/O error, corrupted index, or maxMetrics exceeded.","commonSituations":"High-cardinality queries exceeding maxMetrics; slow disks; corrupted parts; expired deadlines under heavy load.","solutions":["Read the wrapped cause and address it (deadline, limits, or corruption)","Increase -search.max* limits (maxMetrics, maxQueryDuration) if limits were hit","Fix storage issues (disk health, restore corrupted parts)","Narrow the query filters/time range to reduce scan cost"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// pre-validate filters and limits before searching\nif len(tfss) == 0 { return nil, nil }\nif maxMetrics <= 0 { maxMetrics = defaultMaxMetrics }","typeGuard":null,"tryCatchPattern":"metricIDs, err := db.SearchMetricIDs(qt, tfss, tr, maxMetrics, deadline)\nif err != nil {\n    if strings.Contains(err.Error(), \"deadline\") {\n        // narrow time range and retry\n    } else {\n        return nil, fmt.Errorf(\"metric id lookup failed: %w\", err)\n    }\n}","preventionTips":["Set deadlines and maxMetrics proportional to cardinality","Narrow time ranges and filters in queries","Keep tag-filter caches warm (repeated queries reuse cache)","Monitor and repair storage/disk issues promptly"],"tags":["storage","index-db","query","limits"],"backgroundTag":"index-search-failed","analyzedSha":"5079fb58f1e8e62113f90c945ad71586c797d770","analyzedAt":"2026-09-03T18:10:26.153Z","contentChangedAt":"2026-09-03T18:10:26.153Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}