temporalio/temporal · error

Found overlapping incoming slices, left slice range: %v, rig

Error message

Found overlapping incoming slices, left slice range: %v, right slice range: %v

What it means

validateSlicesOrderedDisjoint panics if any adjacent pair in the incoming slice list overlaps: slice[i].Range.ExclusiveMax > slice[i+1].Range.InclusiveMin. It is called by MergeSlices and AppendSlices as a precondition that the caller passed an ordered, disjoint set of slices. The invariant check guarantees the merge/append algorithms can assume sorted input.

Source

Thrown at service/history/queues/reader.go:573

	mergedSlices := lastSlice.MergeWithSlice(incomingSlice)
	slices.Remove(lastElement)
	for _, mergedSlice := range mergedSlices {
		slices.PushBack(mergedSlice)
	}
}

func validateSlicesOrderedDisjoint(
	slices []Slice,
) {
	if len(slices) <= 1 {
		return
	}

	for idx, slice := range slices[:len(slices)-1] {
		nextSlice := slices[idx+1]
		if slice.Scope().Range.ExclusiveMax.CompareTo(nextSlice.Scope().Range.InclusiveMin) > 0 {
			panic(fmt.Sprintf(
				"Found overlapping incoming slices, left slice range: %v, right slice range: %v",
				slice.Scope().Range,
				nextSlice.Scope().Range,
			))
		}
	}
}

View on GitHub (pinned to bde624efd1)

Solutions

  1. Sort the slice list by Scope().Range.InclusiveMin before passing it in
  2. Verify the producer of these slices (DB query, split logic) returns ordered disjoint ranges; add an ORDER BY on task_id/task visibility columns
  3. Merge overlapping slices yourself (or via SliceImpl.MergeWithSlice) so the final list is disjoint before calling the API

Example fix

// before
reader.AppendSlices(sliceB, sliceA) // unsorted or overlapping

// after
sort.Slice(slices, func(i, j int) bool {
  return slices[i].Scope().Range.InclusiveMin.CompareTo(slices[j].Scope().Range.InclusiveMin) < 0
})
// ensure disjoint, then:
reader.AppendSlices(slices...)
Defensive patterns

Strategy: validation

Validate before calling

func orderedDisjoint(slices []queues.Slice) bool {
  for i := 0; i < len(slices)-1; i++ {
    if slices[i].Scope().Range.ExclusiveMax.CompareTo(slices[i+1].Scope().Range.InclusiveMin) > 0 {
      return false
    }
  }
  return true
}

Prevention

When it happens

Trigger: Calling AppendSlices(s1, s2) or MergeSlices(s1, s2) where an earlier slice's ExclusiveMax exceeds a later slice's InclusiveMin; passing unsorted slices where sorting happens to also produce an overlap.

Common situations: Constructing slices from a DB query that was not ordered by task_id; splitting/merging logic in custom task processing that reassembles slices in wrong order; after version upgrades that changed key encoding.

Related errors


AI-assisted analysis of temporalio/temporal@bde624efd1 (2026-09-01). Data as JSON: /api/errors/d50885bff1c94e69. Report an issue: GitHub.