{"record":{"id":"048f369f7ad05922","repo":"dgraph-io/badger","slug":"errstop","errorCode":"errStop","errorMessage":"Stop iteration","messagePattern":"Stop iteration","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"value.go","lineNumber":56,"sourceCode":"\tbitDelete                 byte = 1 << 0 // Set if the key has been deleted.\n\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.","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/dgraph-io/badger/blob/2a001d466f6b71a917319a1db41f99860e16e269/value.go#L38-L74","documentation":"errStop is a sentinel control-flow error (declared alongside the value-log header bits in value.go) used to abort an iteration early by returning it from a callback. It does not indicate failure: callers such as read_bench check for it explicitly after the walk (errors.Is) and treat it as a normal stop request — e.g. the benchmark cancels the context and returns errStop once the sample size is reached. Guard-style usage: the fault input is not data but a caller-decided termination condition.","triggerScenarios":"Thrown at value.go:56 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat this sentinel as a normal termination signal, not an error: after the iteration call, check errors.Is(err, errStop) and return nil/success in that branch","Do not retry or log it as a failure; it is intentionally returned by your own callback to stop traversal","If you control the loop, prefer a context cancellation or a boolean return over an error sentinel for early stopping"],"exampleFix":null,"handlingStrategy":"type-guard","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"}