JuliusBrussee/caveman · error
cachebench: duplicate trace request %q
Error message
cachebench: duplicate trace request %q
What it means
Two trace records share the same RequestID, which would make the by-ID join ambiguous. The evaluator builds a map keyed by RequestID and rejects the second occurrence, quoting the duplicated ID.
Source
Thrown at cacheengine/cachebench/observed.go:46
QualityEvidenceSHA256: bodyDigest(verification.Evidence), Usage: append(json.RawMessage(nil), rawUsage...),
}
}
// EvaluateObservedAgainstTrace requires exact request population and body joins.
func EvaluateObservedAgainstTrace(records []ObservationRecord, trace []TraceRecord, target Target) (Report, error) {
if err := validateObservationRecords(records); err != nil {
return Report{}, err
}
if len(records) != len(trace) {
return Report{}, fmt.Errorf("cachebench: observation population %d does not match trace population %d", len(records), len(trace))
}
byID := make(map[string]TraceRecord, len(trace))
for index, request := range trace {
if request.Schema != TraceSchema && request.Schema != TraceSchemaV2 || strings.TrimSpace(request.RequestID) == "" {
return Report{}, fmt.Errorf("cachebench: trace request %d has invalid schema or request_id", index)
}
if _, exists := byID[request.RequestID]; exists {
return Report{}, fmt.Errorf("cachebench: duplicate trace request %q", request.RequestID)
}
if strings.TrimSpace(request.Provider) == "" || strings.TrimSpace(request.Epoch) == "" || !validUniqueJSONObject(request.Body) || request.BodySHA256 == "" || request.BodySHA256 != bodyDigest(request.Body) {
return Report{}, fmt.Errorf("cachebench: trace request %q has invalid identity, body, or digest", request.RequestID)
}
if request.StableSegmentCount < 0 || request.StableSegmentCount > len(request.Prefix) || !validPrefix(request.Prefix) {
return Report{}, fmt.Errorf("cachebench: trace request %q has invalid prefix", request.RequestID)
}
byID[request.RequestID] = request
}
for _, record := range records {
request, exists := byID[record.RequestID]
if !exists {
return Report{}, fmt.Errorf("cachebench: observation request %q absent from trace", record.RequestID)
}
if record.Provider != request.Provider || record.Epoch != request.Epoch {
return Report{}, fmt.Errorf("cachebench: observation request %q provider/epoch mismatch", record.RequestID)
}
if record.RequestBodySHA256 == "" || record.RequestBodySHA256 != request.BodySHA256 {View on GitHub (pinned to 27d5a3981a)
Solutions
- Deduplicate the trace by request_id, keeping one record per ID.
- Do not append a new replay to an existing trace file; write to a fresh file per epoch.
- If both entries are genuinely distinct requests, assign unique request_ids at generation time.
Defensive patterns
Strategy: validation
Validate before calling
func dedupeTrace(trace []TraceRecord) ([]TraceRecord, error) {
seen := map[string]bool{}
out := make([]TraceRecord, 0, len(trace))
for _, r := range trace {
if seen[r.RequestID] {
return nil, fmt.Errorf("duplicate trace request %q", r.RequestID)
}
seen[r.RequestID] = true
out = append(out, r)
}
return out, nil
} Prevention
- Write each replay epoch to a fresh trace file; never append across runs.
- Deduplicate merged trace shards by request_id before evaluation.
- Make request_id generation idempotent per logical request.
When it happens
Trigger: EvaluateObservedAgainstTrace over a trace where any RequestID appears more than once — e.g. concatenated trace files, or a retry that appended the same request twice.
Common situations: Merging trace shards that overlap; replay reruns appending to an existing trace file instead of truncating; exporters that reuse sequence numbers after a restart.
Related errors
- cachebench: observation population %d does not match trace p
- cachebench: trace request %q has invalid identity, body, or
- cachebench: observation request %q absent from trace
- cachebench: observation request %q provider/epoch mismatch
- cachebench: observation request %q body digest mismatch
AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15).
Data as JSON: /api/errors/1648c69f3e80569b.
Report an issue: GitHub.