{"record":{"id":"cba2fcd6e12eeaef","repo":"JuliusBrussee/caveman","slug":"cachebench-replay-schedule-duration-overflow","errorCode":null,"errorMessage":"cachebench: replay schedule duration overflow","messagePattern":"cachebench: replay schedule duration overflow","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/replay.go","lineNumber":412,"sourceCode":"\t\t}\n\t\ttokens[record.TokenBasis] = true\n\t\tif record.DeclaredInputTokens <= 0 || record.DeclaredInputTokens < record.PrefixTokens || record.MaxOutputTokens <= 0 || !requestBudgetMatchesBody(record) {\n\t\t\treturn ReplayPreflight{}, fmt.Errorf(\"cachebench: replay request %q has invalid billed-token budget\", record.RequestID)\n\t\t}\n\t\tinput, output := int64(record.DeclaredInputTokens), int64(record.MaxOutputTokens)\n\t\tif input > limits.MaxDeclaredBilledTokens-worstCase || output > limits.MaxDeclaredBilledTokens-worstCase-input {\n\t\t\treturn ReplayPreflight{}, fmt.Errorf(\"cachebench: replay declared billed-token ceiling exceeds limit %d\", limits.MaxDeclaredBilledTokens)\n\t\t}\n\t\tdeclaredInput += input\n\t\tdeclaredOutput += output\n\t\tworstCase += input + output\n\t\tif !previous.IsZero() {\n\t\t\tgap, err := scaledReplayGap(at.Sub(previous), timeScale)\n\t\t\tif err != nil || gap > limits.MaxGap {\n\t\t\t\treturn ReplayPreflight{}, fmt.Errorf(\"cachebench: replay gap before %q exceeds limit %s\", record.RequestID, limits.MaxGap)\n\t\t\t}\n\t\t\tif int64(gap) > math.MaxInt64-scheduled {\n\t\t\t\treturn ReplayPreflight{}, errors.New(\"cachebench: replay schedule duration overflow\")\n\t\t\t}\n\t\t\tscheduled += int64(gap)\n\t\t}\n\t\tprevious = at\n\t}\n\tbases := make([]string, 0, len(timing))\n\tfor basis := range timing {\n\t\tbases = append(bases, basis)\n\t}\n\tsort.Strings(bases)\n\ttokenBases := make([]string, 0, len(tokens))\n\tfor basis := range tokens {\n\t\ttokenBases = append(tokenBases, basis)\n\t}\n\tsort.Strings(tokenBases)\n\treturn ReplayPreflight{\n\t\tRequests: len(records), DeclaredInputTokens: declaredInput,\n\t\tDeclaredMaxOutputTokens: declaredOutput, DeclaredBilledTokens: worstCase,","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/cacheengine/cachebench/replay.go#L394-L430","documentation":"Raised in ValidateReplay when computing the total replay schedule: summing per-request timing (gaps scaled by timeScale, request durations) overflows the time.Duration/int64 range. A trace with extreme PreGap values or timestamps can produce a schedule beyond ~292 years.","triggerScenarios":"Thrown at cacheengine/cachebench/replay.go:412 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Clamp or drop rows with absurd gap/PreGap values before building the trace","Reduce timeScale to compress an otherwise long schedule","Split the trace into multiple replay runs with bounded horizons"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}