{"record":{"id":"0466aca4b0c3c414","repo":"dgraph-io/badger","slug":"errtruncate","errorCode":"errTruncate","errorMessage":"Do truncate","messagePattern":"Do truncate","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"value.go","lineNumber":57,"sourceCode":"\tbitValuePointer           byte = 1 << 1 // Set if the value is NOT stored directly next to key.\n\tbitDiscardEarlierVersions byte = 1 << 2 // Set if earlier versions can be discarded.\n\t// Set if item shouldn't be discarded via compactions (used by merge operator)\n\tbitMergeEntry byte = 1 << 3\n\t// The MSB 2 bits are for transactions.\n\tbitTxn    byte = 1 << 6 // Set if the entry is part of a txn.\n\tbitFinTxn byte = 1 << 7 // Set if the entry is to indicate end of txn in value log.\n\n\tmi int64 = 1 << 20 //nolint:unused\n\n\t// size of vlog header.\n\t// +----------------+------------------+\n\t// | keyID(8 bytes) |  baseIV(12 bytes)|\n\t// +----------------+------------------+\n\tvlogHeaderSize = 20\n)\n\nvar errStop = errors.New(\"Stop iteration\")\nvar errTruncate = errors.New(\"Do truncate\")\n\ntype logEntry func(e Entry, vp valuePointer) error\n\ntype safeRead struct {\n\tk []byte\n\tv []byte\n\n\trecordOffset uint32\n\tlf           *logFile\n}\n\n// hashReader implements io.Reader, io.ByteReader interfaces. It also keeps track of the number\n// bytes read. The hashReader writes to h (hash) what it reads from r.\ntype hashReader struct {\n\tr         io.Reader\n\th         hash.Hash32\n\tbytesRead int // Number of bytes read.\n}","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/dgraph-io/badger/blob/2a001d466f6b71a917319a1db41f99860e16e269/value.go#L39-L75","documentation":"errTruncate is a sentinel error meaning a value-log entry header or checksum was invalid in a way that requires truncating the corrupt tail of the file. It is returned by header parsing (e.g. when a key length exceeds uint16, an impossible value) and consumed by the memtable replay loop, which breaks out of the loop on errTruncate or io.ErrUnexpectedEOF so replay can proceed with the intact prefix of the log. It signals corruption of the value log tail, commonly after an unclean shutdown mid-write.","triggerScenarios":"Thrown at value.go:57 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Let the existing replay path handle it: the read loop stops at errTruncate and Badger's truncate logic (opt value log truncation) discards the corrupt tail on open","Reopen with the value-log-replay/truncate option enabled so the damaged tail is removed automatically","If the error persists, back up the .vlog files and follow the Badger troubleshooting docs for value log corruption","Investigate the cause — power loss, killed process, or disk faults — to avoid repeated corruption"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2a001d466f6b71a917319a1db41f99860e16e269","analyzedAt":"2026-09-05T13:00:02.264Z","contentChangedAt":"2026-09-05T13:00:02.264Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}