{"record":{"id":"3d5797291435e5f2","repo":"weaviate/weaviate","slug":"getting-vector-for-id","errorCode":null,"errorMessage":"Getting vector for id","messagePattern":"Getting vector for id","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/repos/db/vector/compressionhelpers/compression.go","lineNumber":284,"sourceCode":"\tcompressedVector2, err := compressor.compressedVectorFromID(ctx, id2)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tdist, err := compressor.DistanceBetweenCompressedVectors(compressedVector1, compressedVector2)\n\treturn dist, err\n}\n\nfunc (compressor *quantizedVectorsCompressor[T]) getCompressedVectorForID(ctx context.Context, id uint64) ([]T, error) {\n\tidBytes := make([]byte, 8)\n\tcompressor.storeId(idBytes, id)\n\tbucket := compressor.compressedBucket()\n\tif bucket == nil {\n\t\treturn nil, lsmkv.ErrAlreadyClosed\n\t}\n\tcompressedVector, err := bucket.Get(idBytes)\n\tif err != nil {\n\t\treturn nil, errors.Wrap(err, \"Getting vector for id\")\n\t}\n\tif len(compressedVector) == 0 {\n\t\tif compressor.vectorForID != nil {\n\t\t\treturn compressor.recoverCompressedVector(ctx, id, idBytes, bucket)\n\t\t}\n\t\treturn nil, storobj.NewErrNotFoundf(id, \"getCompressedVectorForID\")\n\t}\n\n\treturn compressor.quantizer.FromCompressedBytes(compressedVector), nil\n}\n\n// recoverCompressedVector fetches the raw vector, encodes it, and persists\n// it to the compressed bucket so future reads don't need recovery.\n// Write-back is a cache-fill optimization: if the bucket is read-only (e.g.\n// shard temporarily READONLY during UpdateVectorIndexConfigs, resource\n// pressure, or backup), the persist is skipped and the encoded vector is\n// returned. A future read will re-encode if the bucket is still empty for\n// this id, which is acceptable for this rare path.","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/repos/db/vector/compressionhelpers/compression.go#L266-L302","documentation":"This error wraps a lower-level lsmkv bucket read failure that occurred while fetching a compressed (quantized) vector for a given internal document id. The quantized-vectors compressor looks up the vector bytes in the compressed-vector bucket; if the bucket backend returns any error (I/O failure, corrupt segment, closed segment handle), it is wrapped with this message so the caller knows the failure was during vector retrieval, not the fallback path.","triggerScenarios":"Calling getCompressedVectorForID (directly or via vector retrieval during search/reindex) when the underlying lsmkv compressed bucket's Get fails — e.g. disk I/O error, corrupted segment file, or a race with bucket shutdown where the bucket is partially closed.","commonSituations":"Disk full or failing disk on a shard directory; LSM segment corruption after an unclean shutdown; concurrent shard drop/compaction racing a query; read-only filesystem during recovery attempts.","solutions":["Check shard logs just before this error for lsmkv compaction/segment errors to identify the failing segment file","Verify disk health and free space on the data volume; repair or replace failing storage","Stop writes, restart the node to reopen buckets cleanly; if corruption persists, restore the shard from backup or recalculate vectors by dropping and re-creating the quantization (re-vectorize from the original vector index or re-import)","If it recurs on a specific shard, delete that shard's compressed bucket directory and let the compressor rebuild it from the primary vector index"],"exampleFix":"// before: raw lsmkv error surfaces with no shard context\ncompressedVector, err := bucket.Get(idBytes)\n// after: wrap with action logging so operators can locate the failing shard\ncompressedVector, err := bucket.Get(idBytes)\nif err != nil {\n\tcompressor.logger.WithField(\"action\", \"getCompressedVectorForID\").Warnf(\"getting vector for id %d: %v\", id, err)\n\treturn nil, errors.Wrap(err, \"Getting vector for id\")\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"func isBucketClosedErr(err error) bool { return errors.Is(err, lsmkv.ErrAlreadyClosed) }\n","tryCatchPattern":"v, err := compressor.getCompressedVectorForID(ctx, id)\nif err != nil {\n\tif errors.Is(err, storobj.ErrNotFound) {\n\t\t// object genuinely absent\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"compressed vector fetch failed: %w\", err)\n}","preventionTips":["Monitor disk health and free space on data volumes","Alert on lsmkv compaction/segment errors in shard logs","Avoid dropping shards while queries are in flight","Restore from backup promptly after detecting segment corruption"],"tags":["lsmkv","storage","vector-index","io-error"],"backgroundTag":"bucket-read-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"}