Skip to content

fix: enforce SQS 1 MB batch byte limit#845

Open
alexluong wants to merge 1 commit intomainfrom
fix/sqs-batch-byte-limit
Open

fix: enforce SQS 1 MB batch byte limit#845
alexluong wants to merge 1 commit intomainfrom
fix/sqs-batch-byte-limit

Conversation

@alexluong
Copy link
Copy Markdown
Collaborator

Summary

gocloud.dev's SQS topic driver batches Send() calls via SendMessageBatch (up to 10 messages per batch) but does not enforce SQS's 1 MB total batch size limit — it relies on SQS to reject oversized batches at the API level.

When log entries carry large payloads (e.g., large request/response bodies), the combined batch can exceed 1 MB, causing SQS to reject the entire batch with BatchRequestTooLong. This failure cascades: the log entry never gets persisted, and the retry scheduler can't find a prior attempt in the logstore, triggering an infinite retry loop (see #663).

This PR sets MaxBatchByteSize: 1_048_576 on the gocloud TopicOptions so the batcher splits oversized batches before they reach SQS. If a single message exceeds 1 MB, gocloud returns ErrMessageTooLarge instead of a cryptic SQS batch error.

Changes

  • Pass TopicOptions with BatcherOptions.MaxBatchByteSize set to 1 MB when opening SQS topics in queue_awssqs.go

Test plan

  • Verified compilation
  • Deploy to staging with SQS backend and send events with large payloads (>100 KB) at high concurrency to confirm batches are split correctly

🤖 Generated with Claude Code

gocloud.dev's SQS driver batches Send() calls internally via
SendMessageBatch (up to 10 messages) but does not enforce SQS's 1 MB
batch size limit. When log entries carry large payloads the batch can
exceed 1 MB, causing SQS to reject the entire batch. This cascades
into a permanent retry loop because the log entry never gets persisted
and the retry scheduler cannot find a prior attempt.

Set MaxBatchByteSize to 1 MB so gocloud splits oversized batches
before they reach SQS.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@alexluong alexluong force-pushed the fix/sqs-batch-byte-limit branch from 971064b to ebe2e42 Compare April 20, 2026 13:49
@alexluong alexluong mentioned this pull request Apr 20, 2026
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.

2 participants