Segment must be less than TotalSegments

TL;DR — In a parallel Scan, each worker sets Segment (its slice index) and TotalSegments (how many slices). DynamoDB requires 0 ≤ Segment < TotalSegments, and both must be supplied together. A Segment equal to or above TotalSegments is rejected. Assign each worker a distinct Segment from 0 to TotalSegments − 1.

What it means

ValidationException: The Segment parameter is out of range. Segment must be
less than TotalSegments (or: Segment must be greater than or equal to 0)

A parallel scan divides the table into TotalSegments slices; each worker scans one slice identified by Segment. Valid Segment values are 0 through TotalSegments − 1. TotalSegments itself must be between 1 and 1,000,000. If you supply one without the other, or a Segment outside the range, DynamoDB rejects the call. It's an HTTP 400 ValidationException, client-side, and not retryable until the parameters are valid.

Why it happens

  • Off-by-one segment assignment — with TotalSegments = 4, using Segment values 1..4 instead of 0..3.
  • Segment ≥ TotalSegments — a worker index that meets or exceeds the slice count.
  • Only one of the pair supplied — passing Segment without TotalSegments (or vice-versa); both are required for a parallel scan.
  • A dynamic worker pool mismatchTotalSegments set to a different value than the number of workers actually launched, so some workers get out-of-range indices.

How to fix it

  1. Assign segments 0 to TotalSegments − 1 — one distinct Segment per worker.
  2. Always pass both parameters together on every parallel-scan request.
  3. Keep TotalSegments equal to the worker count and within 1..1,000,000.
  4. Use zero-based indexing when mapping a worker's ordinal to its Segment.

Console 없이 DynamoDB 작업하기

DynoTable은 DynamoDB를 위한 빠른 데스크톱 클라이언트입니다 — 테이블을 탐색하고, SQL 스타일 쿼리를 실행하고, 항목을 로컬에서 편집하세요.