{"record":{"id":"4add59cb5c81f6ae","repo":"thanos-io/thanos","slug":"corrupted-identifier","errorCode":null,"errorMessage":"corrupted identifier","messagePattern":"corrupted identifier","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/store/postings_codec.go","lineNumber":253,"sourceCode":"\t}\n\n\t// Read next chunk into it.db.B.\n\tchunkType := it.input[0]\n\tit.input = it.input[1:]\n\n\tif len(it.input) < 3 {\n\t\tit.err = io.ErrUnexpectedEOF\n\t\treturn false\n\t}\n\n\tchunkLen := int(it.input[0]) | int(it.input[1])<<8 | int(it.input[2])<<16\n\tit.input = it.input[3:]\n\n\tswitch chunkType {\n\tcase chunkTypeStreamIdentifier:\n\t\tconst magicBody = \"sNaPpY\"\n\t\tif chunkLen != len(magicBody) {\n\t\t\tit.err = fmt.Errorf(\"corrupted identifier\")\n\t\t\treturn false\n\t\t}\n\t\tif string(it.input[:len(magicBody)]) != magicBody {\n\t\t\tit.err = fmt.Errorf(\"got bad identifier %s\", string(it.input[:6]))\n\t\t\treturn false\n\t\t}\n\t\tit.input = it.input[6:]\n\t\tit.readSnappyIdentifier = true\n\t\treturn it.readNextChunk(nil)\n\tcase chunkTypeCompressedData:\n\t\tif !it.readSnappyIdentifier {\n\t\t\tit.err = fmt.Errorf(\"missing magic snappy marker\")\n\t\t\treturn false\n\t\t}\n\t\tif len(it.input) < 4 {\n\t\t\tit.err = io.ErrUnexpectedEOF\n\t\t\treturn false\n\t\t}","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/store/postings_codec.go#L235-L271","documentation":"This is a minimal in-replica snappy framing reader (readNextChunk). A stream-identifier chunk (chunkTypeStreamIdentifier) must carry exactly the 6-byte body \"sNaPpY\"; any other length means the framed stream is corrupt, so iteration stops with this error.","triggerScenarios":"Next() -> readNextChunk encountering a stream-identifier chunk whose chunkLen != 6 while parsing streamed snappy postings — truncated or bit-rotted encoded postings bytes.","commonSituations":"Disk corruption of cached postings; truncation during cache write/copy; decoding arbitrary bytes as streamed snappy.","solutions":["Treat the postings entry as corrupt and evict it from the cache","Re-encode/rebuild the cache from the index","Verify storage medium health (fsck, disk SMART) if corruption recurs"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"func validateSnappyFraming(input []byte) error {\n    if len(input) < 10 || !bytes.Contains(input, []byte(\"\\xff\\x06\\x00\\x00sNaPpY\")) {\n        return errors.New(\"missing snappy stream identifier\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"it := newStreamedDiffVarintPostings(body, false)\nfor it.Next() {\n    v := it.At()\n}\nif it.Err() != nil {\n    if strings.Contains(it.Err().Error(), \"corrupted identifier\") {\n        return evictCacheEntry(key) // treat as corrupt, refetch from index\n    }\n    return it.Err()\n}","preventionTips":["Evict and re-encode cache entries on any framing error instead of retrying the same bytes","Verify disk health if corruption recurs (fsck, SMART)","Avoid copying/truncating cache files while the server is running"],"tags":["snappy","corruption","streaming"],"backgroundTag":"checksum-mismatch","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}