DynamoDB Streams: TrimmedDataAccessException

TL;DR — DynamoDB Streams keeps records for 24 hours; older records are trimmed and gone from the stream. This exception means you asked for a position that has been trimmed — a checkpoint more than a day old, usually from a consumer that was down or fell behind. You can't get those records back from the stream: resume from TRIM_HORIZON (oldest surviving record) and reconcile the gap from the table itself.

What it means

TrimmedDataAccessException: The data you are trying to access has been trimmed.

Unlike an expired iterator — where only your position handle went stale — trimmed data is genuinely removed. Requesting a shard iterator at a trimmed SequenceNumber, or reading a shard whose records have aged out, throws this. The stream is a rolling 24-hour buffer, not an archive.

Why it happens

  • The consumer was down for more than 24 hours — an outage, a paused worker, a forgotten disabled trigger — and its checkpoint now points into trimmed territory.
  • Processing lag exceeded retention — the consumer runs, but slower than the write rate, and drifted more than a day behind.
  • A stale stored checkpoint — restarting an old consumer with a SequenceNumber persisted weeks ago.
  • Reading an old shard end-to-end — walking the shard lineage of a long-lived stream and requesting ranges that predate retention.

How to fix it

  1. Resume from the oldest available record and accept the gap:

    const {ShardIterator} = await streams.send(
      new GetShardIteratorCommand({
        StreamArn: streamArn,
        ShardId: shardId,
        ShardIteratorType: 'TRIM_HORIZON' // oldest untrimmed record
      })
    );

    Use LATEST instead if only new activity matters.

  2. Reconcile the missed window from the source of truth — the table still has the current state of every item. A bounded Scan/Query over the affected keys (or an export for large tables) rebuilds what the trimmed records would have told you, minus intermediate versions.

  3. Alert on consumer lag — monitor the age of the records you're processing (or Lambda's IteratorAge metric) and page long before it approaches 24 hours.

  4. Need longer retention? Stream into a durable buffer as records arrive (e.g. Kinesis Data Streams via Kinesis adapter patterns, or persist processed records yourself) — DynamoDB Streams itself cannot be extended past 24 hours.

  5. Reset the checkpoint after recovery. Persist the new SequenceNumber from TRIM_HORIZON so the consumer does not resume the old trimmed position on restart.

In DynoTable

After a trim gap, reconcile current item state from the table — open it with ⌘K and browse or filter the keys your consumer missed. DynoTable shows live table data independent of the 24-hour stream window.

Size the catch-up read with the pricing calculator. Copy the table's LatestStreamArn from the metadata panel before you restart the consumer. Switch profiles with ⌘P; see Connect to AWS and Install.

Sources

References

Last verified 2026-07-13 against the official AWS documentation linked above.

Work with DynamoDB without the Console

A fast DynamoDB desktop client that runs the real SQL DynamoDB can’t — JOINs, GROUP BY, aggregates — with visual editing and an AI agent on your own Bedrock keys.

Free 30-day trial, no credit card — then the Free plan with no time limit.