{"record":{"id":"859485dee07b1a6a","repo":"weaviate/weaviate","slug":"read-level","errorCode":null,"errorMessage":"read level","messagePattern":"read level","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"adapters/repos/db/vector/hnsw/compact/snapshot_reader.go","lineNumber":203,"sourceCode":"\t_, _ = hasher.Write(metadata)\n\tif hasher.Sum32() != checksum {\n\t\treturn 0, fmt.Errorf(\"metadata checksum mismatch\")\n\t}\n\n\t// Parse metadata\n\tmetaReader := bytes.NewReader(metadata)\n\n\t// Entrypoint\n\tvar entrypoint uint64\n\tif err := binary.Read(metaReader, binary.LittleEndian, &entrypoint); err != nil {\n\t\treturn 0, errors.Wrap(err, \"read entrypoint\")\n\t}\n\tres.Graph.Entrypoint = entrypoint\n\n\t// Level\n\tvar level uint16\n\tif err := binary.Read(metaReader, binary.LittleEndian, &level); err != nil {\n\t\treturn 0, errors.Wrap(err, \"read level\")\n\t}\n\tres.Graph.Level = level\n\n\t// isCompressed\n\tvar isCompressed uint8\n\tif err := binary.Read(metaReader, binary.LittleEndian, &isCompressed); err != nil {\n\t\treturn 0, errors.Wrap(err, \"read isCompressed\")\n\t}\n\tres.SetCompressed(isCompressed != 0)\n\n\tif res.Compressed() {\n\t\tif err := r.readCompressionData(metaReader, res); err != nil {\n\t\t\treturn 0, errors.Wrap(err, \"read compression data\")\n\t\t}\n\t}\n\n\t// isEncoded (Muvera)\n\tvar isEncoded uint8","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/weaviate/weaviate/blob/75aa4b6d11f8818305aafd4440b4e32794f7ca04/adapters/repos/db/vector/hnsw/compact/snapshot_reader.go#L185-L221","documentation":"Thrown in SnapshotReader.readMetadata when binary.Read fails to read the 2-byte HNSW graph level (uint16, little-endian) from the snapshot's metadata buffer. The metadata blob itself was already checksum-verified, so reaching this point with too few bytes means the metadata was written shorter than the reader expects — typically a truncated or corrupt snapshot file, or a version/format mismatch. The wrapped io.EOF / ErrUnexpectedEOF propagates up and aborts deserialization of the whole HNSW snapshot.","triggerScenarios":"Calling SnapshotReader.Read on a snapshot file whose metadata section ends before the level field: the file was truncated on disk, the metadata buffer is corrupt despite a passing checksum, or the snapshot was produced by a writer whose metadata layout differs from this reader's expectations.","commonSituations":"Disk full or node crash while the compaction snapshot was being written; restoring/copying shard files manually and truncating the .snapshot file; different Weaviate versions involved in backup restore where the metadata field order changed; corrupted persistent storage.","solutions":["Delete the corrupted snapshot file (and its condensor/tmp artifacts) and restart Weaviate so the snapshot regenerates from the commit log or via a new compaction cycle.","Verify disk health and free space on the volume holding the shard data; check dmesg/filesystem logs for I/O errors around the time it was written.","Check that the Weaviate version that produced the shard matches the one reading it; restore shards only into compatible versions.","If corruption recurs, re-import the collection from a backup taken before the corruption."],"exampleFix":"// operator fix, no code change\n// before (corrupt snapshot present)\nls persistence-dir/<shard>/vector_index/hnsw.snapshot  # partially written\n// after\nrm persistence-dir/<shard>/vector_index/hnsw.snapshot* && restart weaviate","handlingStrategy":"validation","validationCode":"fi, err := os.Stat(snapshotPath); if err != nil || fi.Size() < 32 { /* snapshot missing/truncated -> regenerate before loading */ }","typeGuard":null,"tryCatchPattern":"if err := reader.Read(f); err != nil { if strings.Contains(err.Error(), \"read level\") || errors.Is(err, io.ErrUnexpectedEOF) { os.Remove(snapshotPath); /* trigger recompaction/rebuild */ } return err }","preventionTips":["Ensure adequate free disk space before compaction runs","Shut down nodes cleanly before copying or restoring shard directories","Use the backup module (s3/gcs/azure) for consistent shard copies","Keep the whole cluster on the same Weaviate version"],"tags":["hnsw","snapshot","corruption","truncated-file","deserialization"],"backgroundTag":"snapshot-file-corrupted","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"}