JuliusBrussee/caveman · error

cachebench: positive replay request, token, gap…

Error message

cachebench: positive replay request, token, gap, schedule-drift, and concurrency limits required; concurrency cannot exceed 1024

What it means

Raised in ValidateReplay: any of ReplayLimits' MaxRequests, MaxDeclaredBilledTokens, MaxGap, MaxScheduleDrift, or MaxConcurrency is non-positive, or MaxConcurrency exceeds 1024. These budgets bound worst-case cost and parallelism, so unset or absurd values are refused up front.

Solutions

  1. Set all ReplayLimits fields to positive values before preflight
  2. Keep MaxConcurrency at or below 1024
  3. Derive limits from the trace's actual request count and token budgets rather than zero-value structs
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cacheengine/cachebench/replay.go:360 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18). Data as JSON: /api/errors/47df1e7486ce876b. Report an issue: GitHub.

Appendix: source

Thrown at cacheengine/cachebench/replay.go:360

	Engine    *cacheengine.Engine
	Transport ReplayTransport
	Verifier  ReplayVerifier
	Limits    ReplayLimits
	// Target enables a post-engine eligible-population gate before any provider
	// call. Nil leaves target evaluation to caller.
	Target    *Target
	TimeScale float64
	Now       func() time.Time
	Sleep     func(context.Context, time.Duration) error
}

// ValidateReplay performs zero-network trace, schedule, and budget preflight.
func ValidateReplay(records []TraceRecord, limits ReplayLimits, timeScale float64) (ReplayPreflight, error) {
	if len(records) == 0 {
		return ReplayPreflight{}, errors.New("cachebench: replay trace is empty")
	}
	if limits.MaxRequests <= 0 || limits.MaxDeclaredBilledTokens <= 0 || limits.MaxGap <= 0 || limits.MaxScheduleDrift <= 0 || limits.MaxConcurrency <= 0 || limits.MaxConcurrency > 1024 {
		return ReplayPreflight{}, errors.New("cachebench: positive replay request, token, gap, schedule-drift, and concurrency limits required; concurrency cannot exceed 1024")
	}
	if len(records) > limits.MaxRequests {
		return ReplayPreflight{}, fmt.Errorf("cachebench: replay population %d exceeds request limit %d", len(records), limits.MaxRequests)
	}
	if timeScale <= 0 || math.IsNaN(timeScale) || math.IsInf(timeScale, 0) || timeScale > 1000 {
		return ReplayPreflight{}, errors.New("cachebench: time scale must be greater than zero and at most 1000")
	}
	seen := make(map[string]bool, len(records))
	timing := map[string]bool{}
	tokens := map[string]bool{}
	var previous time.Time
	var declaredInput, declaredOutput, worstCase, scheduled int64
	for index, record := range records {
		if seen[record.RequestID] {
			return ReplayPreflight{}, fmt.Errorf("cachebench: duplicate replay request %q", record.RequestID)
		}
		seen[record.RequestID] = true
		if record.Schema != TraceSchema {

View on GitHub (pinned to 766dce6b13)