Skip to content

output/aws_dynamodb: chunk batch writes to 25 item limit#4112

Open
twmb wants to merge 1 commit intomainfrom
992
Open

output/aws_dynamodb: chunk batch writes to 25 item limit#4112
twmb wants to merge 1 commit intomainfrom
992

Conversation

@twmb
Copy link
Copy Markdown
Contributor

@twmb twmb commented Mar 17, 2026

Summary

  • Chunks BatchWriteItem calls into groups of 25 items per the DynamoDB API limit, instead of sending all items at once and falling back to expensive one-by-one writes on failure
  • Resets backoff between chunks so each chunk gets a fresh retry budget
  • Marks items in unattempted chunks as failed in BatchError when a chunk fails, preventing silent data loss

Test plan

  • Existing unit tests pass (go test ./internal/impl/aws/dynamodb/...)
  • Manual test with batch sizes > 25 against a real DynamoDB table
  • Integration tests (require Docker)

Closes #992

🤖 Generated with Claude Code

@claude

This comment was marked as resolved.

Comment thread internal/impl/aws/dynamodb/output.go
@claude

This comment was marked as resolved.

Comment thread internal/impl/aws/dynamodb/output.go
@claude

This comment was marked as resolved.

@mmatczuk
Copy link
Copy Markdown
Contributor

Please add integration test

DynamoDB BatchWriteItem API limits requests to 25 items. Previously,
exceeding this limit caused a fallback to individual writes. Now batches
are automatically chunked into groups of 25, with backoff reset between
chunks.

Two data-integrity paths are handled explicitly so a chunk failure
cannot silently drop later items:

* When a chunk's BatchWriteItem fails and the individual PutItem
  fallback recovers it, the loop now continues to the next chunk
  instead of returning nil early.
* When a chunk's unprocessed-items retry budget is exhausted, the
  writer returns a service.BatchError that maps each still-unprocessed
  item back to its original batch index via reflect.DeepEqual, with a
  pessimistic whole-chunk-failed fallback if the SDK returns a shape
  we do not recognize. Items in unattempted later chunks are also
  marked failed so upstream retry targets only the unwritten items.

Unit tests cover single-chunk happy path, multi-chunk happy path,
individual-fallback continuation to the next chunk, global-index
arithmetic for partial individual fallback in a non-zero chunk, the
unprocessed-items BatchError path, and the pessimistic fallback when
DeepEqual cannot match. An integration test against dynamodb-local
exercises multi-chunk writes end to end.

Closes #992

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DynamoDB writer should limit write batches to 25 items

3 participants