{"record":{"id":"40340cc6b9893c15","repo":"dgraph-io/badger","slug":"errvaluelogsize","errorCode":"ErrValueLogSize","errorMessage":"Invalid ValueLogFileSize, must be in range [1MB, 2GB)","messagePattern":"Invalid ValueLogFileSize, must be in range \\[1MB, 2GB\\)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":21,"sourceCode":" * SPDX-License-Identifier: Apache-2.0\n */\n\npackage badger\n\nimport (\n\tstderrors \"errors\"\n\t\"math\"\n)\n\nconst (\n\t// ValueThresholdLimit is the maximum permissible value of opt.ValueThreshold.\n\tValueThresholdLimit = math.MaxUint16 - 16 + 1\n)\n\nvar (\n\t// ErrValueLogSize is returned when opt.ValueLogFileSize option is not within the valid\n\t// range.\n\tErrValueLogSize = stderrors.New(\"Invalid ValueLogFileSize, must be in range [1MB, 2GB)\")\n\n\t// ErrKeyNotFound is returned when key isn't found on a txn.Get.\n\tErrKeyNotFound = stderrors.New(\"Key not found\")\n\n\t// ErrTxnTooBig is returned if too many writes are fit into a single transaction.\n\tErrTxnTooBig = stderrors.New(\"Txn is too big to fit into one request\")\n\n\t// ErrConflict is returned when a transaction conflicts with another transaction. This can\n\t// happen if the read rows had been updated concurrently by another transaction.\n\tErrConflict = stderrors.New(\"Transaction Conflict. Please retry\")\n\n\t// ErrReadOnlyTxn is returned if an update function is called on a read-only transaction.\n\tErrReadOnlyTxn = stderrors.New(\"No sets or deletes are allowed in a read-only transaction\")\n\n\t// ErrDiscardedTxn is returned if a previously discarded transaction is reused.\n\tErrDiscardedTxn = stderrors.New(\"This transaction has been discarded. Create a new one\")\n\n\t// ErrEmptyKey is returned if an empty key is passed on an update function.","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/dgraph-io/badger/blob/2a001d466f6b71a917319a1db41f99860e16e269/errors.go#L3-L39","documentation":"ErrValueLogSize is returned by Badger's checkAndSetOptions during Open() when the ValueLogFileSize option is outside [1MB, 2GB). The upper bound exists because the value log file is mmapped and its size must fit in a uint32 (db.go:179); the lower bound is the smallest supported file size.","triggerScenarios":"Calling badger.Open/OpenManaged with opt.ValueLogFileSize < 1<<20 or >= 2<<30, e.g. WithValueLogFileSize(4<<30) or WithValueLogFileSize(512<<10).","commonSituations":"Trying to make value logs tiny to save disk (below 1MB), or huge (4GB/10GB) to reduce file counts, forgetting the 2GB hard cap.","solutions":["Set ValueLogFileSize within [1MB, 2GB), e.g. WithValueLogFileSize(1<<30) for 1GB","Cap large sizes at 2<<30 - 1 and accept more value log files","Validate options before Open() so you fail with your own message"],"exampleFix":"// before\nopts := badger.DefaultOptions(dir).WithValueLogFileSize(4 << 30) // ErrValueLogSize\n// after\nopts := badger.DefaultOptions(dir).WithValueLogFileSize(1 << 30) // 1GB, valid","handlingStrategy":"validation","validationCode":"if vlfSize < 1<<20 || vlfSize >= 2<<30 {\n    return fmt.Errorf(\"ValueLogFileSize must be in [1MB, 2GB), got %d\", vlfSize)\n}","typeGuard":null,"tryCatchPattern":"err := badger.Open(opts)\nif errors.Is(err, badger.ErrValueLogSize) {\n    // clamp and retry\n    opts.ValueLogFileSize = 1 << 30\n    db, err = badger.Open(opts)\n}","preventionTips":["Keep ValueLogFileSize between 1MB and 2GB; default (2GB-bound defaults) is usually fine","Call opts.Validate() before Open()","Centralize option construction in one helper so bounds are enforced once"],"tags":["badger","configuration","validation","storage"],"backgroundTag":"invalid-config-value","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"}