Skip to content

fix(orchestration): redrive lambda misses messages - #1934

Merged
mrgrain merged 1 commit into
mainfrom
mrgrain/fix/orchestration/redrive-lambda-visibility-timeout
Sep 22, 2026
Merged

mrgrain merged 1 commit into
mainfrom
mrgrain/fix/orchestration/redrive-lambda-visibility-timeout

Conversation

@mrgrain

@mrgrain mrgrain commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

The RedriveStateMachine lambda drains the backend DLQ by looping on ReceiveMessageCommand until it gets an empty response. It previously called ReceiveMessageCommand with no WaitTimeSeconds, which defaults to 0. SQS calls this short polling.

During failure recovery, I have observed that the Redrive-Lambda sometimes doesn't drain all messages. This fits with SQS's description of short polling, although I am not entirely sure how exactly. But because the loop exits as soon as result.Messages is empty, a single short-polled empty response ends the redrive early, leaving messages in the DLQ unprocessed.

Adding WaitTimeSeconds: 3 switches to long-polling: SQS waits up to 3s and samples more of the backend before responding, making an early empty result far less likely. Again, I have observed that this resolves the issue and all messages are now drained from the queue.

The PR also lowers VisibilityTimeout from 900s to 60s. The message is only deleted after a successful StartExecutionCommand, so the long timeout has no benefit on success. But it was super annoying on failure because every message was blocked for 15 minutes. Given that the Redrive-Lambda is manually executed, there's not much point in this.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@mrgrain mrgrain changed the title fix(orchestration): redrive lambda visibility timeout too short fix(orchestration): redrive lambda visibility timeout too long for failure recovery Sep 22, 2026
@mrgrain mrgrain changed the title fix(orchestration): redrive lambda visibility timeout too long for failure recovery fix(orchestration): redrive lambda misses messages due to short polling Sep 22, 2026
@mrgrain mrgrain changed the title fix(orchestration): redrive lambda misses messages due to short polling fix(orchestration): redrive lambda misses messages Sep 22, 2026
@rix0rrr
rix0rrr disabled auto-merge September 22, 2026 12:29

@rix0rrr rix0rrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conditionally approved.

I think WaitTimeSeconds should probably be the maximum to minimize the chances of race conditions. It's prooooooooobably fine with 3, but we also don't really have latency requirements so why not minimize them.

@mrgrain
mrgrain added this pull request to the merge queue Sep 22, 2026
@mrgrain

mrgrain commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

As discussed, there's no maximum wait time. It just needs to be lower than http configuration (which can be adjusted as well if needed).

Merged via the queue into main with commit 9a56a7d Sep 22, 2026
14 checks passed
@mrgrain
mrgrain deleted the mrgrain/fix/orchestration/redrive-lambda-visibility-timeout branch September 22, 2026 12:37
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