{"record":{"id":"9f8e44853b5f505f","repo":"dgraph-io/badger","slug":"invalid-valuethreshold-must-be-less-or-equal-to","errorCode":null,"errorMessage":"Invalid ValueThreshold, must be less or equal to %d","messagePattern":"Invalid ValueThreshold, must be less or equal to (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"db.go","lineNumber":165,"sourceCode":"\tif opt.NumCompactors == 1 {\n\t\treturn errors.New(\"Cannot have 1 compactor. Need at least 2\")\n\t}\n\n\tif opt.InMemory && (opt.Dir != \"\" || opt.ValueDir != \"\") {\n\t\treturn errors.New(\"Cannot use badger in Disk-less mode with Dir or ValueDir set\")\n\t}\n\topt.maxBatchSize = (15 * opt.MemTableSize) / 100\n\topt.maxBatchCount = opt.maxBatchSize / int64(skl.MaxNodeSize)\n\n\t// This is the maximum value, vlogThreshold can have if dynamic thresholding is enabled.\n\topt.maxValueThreshold = math.Min(maxValueThreshold, float64(opt.maxBatchSize))\n\tif opt.VLogPercentile < 0.0 || opt.VLogPercentile > 1.0 {\n\t\treturn errors.New(\"vlogPercentile must be within range of 0.0-1.0\")\n\t}\n\n\t// We are limiting opt.ValueThreshold to maxValueThreshold for now.\n\tif opt.ValueThreshold > maxValueThreshold {\n\t\treturn fmt.Errorf(\"Invalid ValueThreshold, must be less or equal to %d\",\n\t\t\tmaxValueThreshold)\n\t}\n\n\t// If ValueThreshold is greater than opt.maxBatchSize, we won't be able to push any data using\n\t// the transaction APIs. Transaction batches entries into batches of size opt.maxBatchSize.\n\tif opt.ValueThreshold > opt.maxBatchSize {\n\t\treturn fmt.Errorf(\"Valuethreshold %d greater than max batch size of %d. Either \"+\n\t\t\t\"reduce opt.ValueThreshold or increase opt.BaseTableSize.\",\n\t\t\topt.ValueThreshold, opt.maxBatchSize)\n\t}\n\t// ValueLogFileSize should be strictly LESS than 2<<30 otherwise we will\n\t// overflow the uint32 when we mmap it in OpenMemtable.\n\tif !(opt.ValueLogFileSize < 2<<30 && opt.ValueLogFileSize >= 1<<20) {\n\t\treturn ErrValueLogSize\n\t}\n\n\tif opt.ReadOnly {\n\t\t// Do not perform compaction in read only mode.","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/dgraph-io/badger/blob/2a001d466f6b71a917319a1db41f99860e16e269/db.go#L147-L183","documentation":"badger stores values smaller than ValueThreshold inline in the LSM tree and larger values in the value log. checkAndSetOptions rejects ValueThreshold values above maxValueThreshold (1GB) because a single value larger than that cap cannot be handled by the value-log design.","triggerScenarios":"Calling badger.Open with opt.ValueThreshold set above 1<<30 (1GB), typically while trying to force all values into the LSM.","commonSituations":"Setting an extremely large ValueThreshold to disable vlog writes; copying a value from a tuned production config into a test.","solutions":["Lower opt.ValueThreshold to at most 1GB (1<<30)","Use the default ValueThreshold (48) unless you have a measured reason to raise it"],"exampleFix":"// before\nopt.ValueThreshold = math.MaxInt64\n// after\nopt.ValueThreshold = 48 // or <= 1<<30","handlingStrategy":"validation","validationCode":"if opt.ValueThreshold > 1<<30 {\n    return errors.New(\"ValueThreshold must be <= 1GB\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use the default 48 unless measured","Cap config values at 1<<30 before applying","Add an options sanity test"],"tags":["badger","configuration","validation"],"backgroundTag":"invalid-enum-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"}