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.

Rebuilding state after a gap means looking at what's actually in the table now — the DynoTable desktop app makes that reconciliation pass a browsable query instead of a script. Sizing the catch-up read? The DynamoDB pricing calculator estimates the RCU cost.

References

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

Work with DynamoDB without the Console

DynoTable is a fast desktop client for DynamoDB — browse tables, run SQL-style queries, and edit items locally.