Repository navigation
feat(sqs-source): make maximum backoff configurable per queue - #7186
LuisNorman wants to merge 3 commits into
Conversation
Adds a new per-queue maximum_backoff option on the SQS source that caps the exponential retry delay used when the source cannot read from SQS. The default stays at 5 minutes so existing deployments see no behavior change. Also makes SqsBackoff resilient to null, zero, and negative durations by falling back to the default, so the shared factory stays safe for all callers of the parameterless overload. Signed-off-by: Luis Norman <lunorman@amazon.com>
PR Reviewer Guide 🔍(Review updated until commit 4abb732)Here are some key observations to aid the review process:
|
| * @return a configured {@link Backoff} | ||
| */ | ||
| public static Backoff createExponentialBackoff(final Duration maximumDelay) { | ||
| final long maxDelayMillis = isValidMaximumDelay(maximumDelay) ? maximumDelay.toMillis() : DEFAULT_MAX_DELAY_MILLIS; |
There was a problem hiding this comment.
Unreachable from config given @DurationMin and silent fallback hides misconfiguration. Throw or log instead?
There was a problem hiding this comment.
Good point. I'll update it to throw IllegalArgumentException on an invalid input.
| r -> SqsClientFactory.createSqsClient(Region.of(r), credentialsProvider)); | ||
| String queueName = queueUrl.substring(queueUrl.lastIndexOf('/') + 1); | ||
| Backoff backoff = SqsBackoff.createExponentialBackoff(); | ||
| Backoff backoff = SqsBackoff.createExponentialBackoff(queueConfig.getMaximumBackoff()); |
There was a problem hiding this comment.
No test that maximum_backoff reaches the backoff, or that values under 20s are rejected.
There was a problem hiding this comment.
Thanks for catching this. I'll add tests to cover both.
There was a problem hiding this comment.
Thanks for adding the tests, @LuisNorman! One small gap: SqsServiceTest doesn't use MockitoExtension, so the getMaximumBackoff() stub is lenient, and the tests still pass if this line goes back to createExponentialBackoff(). Could you add a check that the configured maximum_backoff actually reaches SqsBackoff? A MockedStatic on SqsBackoff with a verify on the configured Duration would do it.
There was a problem hiding this comment.
Good catch. Will wrap the test in MockedStatic<SqsBackoff> and verify the configured Duration reaches the factory.
srikanthpadakanti
left a comment
There was a problem hiding this comment.
Hello @LuisNorman Thank you for this contribution. Can you please address my comments.
Addresses review feedback on PR opensearch-project#7186. - SqsBackoff.createExponentialBackoff(Duration) now throws IllegalArgumentException on null or sub-initial values instead of silently falling back to the default. @DurationMin on QueueConfig already blocks invalid user input, so anything reaching the factory with a bad value is a programming bug. - Adds QueueConfigTest cases for a configured maximum_backoff reaching getMaximumBackoff() and for bean validation rejecting sub-20s values. - Stubs getMaximumBackoff() on SqsServiceTest's QueueConfig mocks to satisfy the new precondition. Signed-off-by: Luis Norman <lunorman@amazon.com>
|
Persistent review updated to latest commit 56040d1 |
|
Hi @srikanthpadakanti, the follow-up commit addresses both review comments and CI is green. Happy to make any other changes you'd like. |
| .buildValidatorFactory()) { | ||
| final Validator validator = factory.getValidator(); | ||
| final Set<ConstraintViolation<QueueConfig>> violations = validator.validate(queueConfig); | ||
| assertTrue( |
There was a problem hiding this comment.
Small style request: Data Prepper prefers Hamcrest for new assertions. Could you switch the new ones here (lines 50, 61 and 78) to assertThat(...)? For example, assertThat(queueConfig.getMaximumBackoff(), equalTo(Duration.ofMinutes(10))), and for the violations, assertThat(violations, hasItem(...)) on the property path. That would match what you already did nicely in SqsBackoffTest. Thanks!
There was a problem hiding this comment.
Will switch the three new assertions to Hamcrest.
|
Thanks for the quick turnaround on the earlier feedback! A minor note: the description still says |
|
Will update the description to match. |
… and switch new assertions to Hamcrest Addresses follow-up review feedback on PR opensearch-project#7186. - SqsServiceTest now wraps start() in MockedStatic<SqsBackoff> and verifies the configured Duration reaches SqsBackoff.createExponentialBackoff. Previously the stub on getMaximumBackoff() was lenient and the test still passed if SqsService reverted to the no-arg overload. - Converts the three new QueueConfigTest assertions to Hamcrest to match the project's assertion convention. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WHJ5hyg48TRqwezQFhNv8a Signed-off-by: Luis Norman <lunorman@amazon.com>
|
Persistent review updated to latest commit 4abb732 |
srikanthpadakanti
left a comment
There was a problem hiding this comment.
LGTM. Approving.
Description
Adds a new per-queue
maximum_backoffoption on thesqssource that caps the exponential retry delay used when the source cannot read from Amazon SQS. The default stays at 5 minutes so existing deployments see no behavior change.Operators of pipelines pulling from Amazon SQS sometimes need to shorten or lengthen the retry ceiling. Lower it to recover faster from transient failures. Raise it to be gentler during longer outages. The option exposes that lever without changing the shared
SqsBackofffactory's default.Changes:
maximum_backoffoption onQueueConfigwith@DurationMin(seconds = 20). The floor matchesSqsBackoff.INITIAL_DELAY_MILLIS. Armeria'sBackoff.exponentialthrows if max is below initial.SqsBackoff.createExponentialBackoff(Duration)overload that throwsIllegalArgumentExceptionon null or sub-initial inputs so misuse surfaces at startup instead of being masked by the default.SqsServiceconstructs the backoff per queue fromqueueConfig.getMaximumBackoff().Issues Resolved
Resolves #3744
Follow-up: a companion PR will extend the same
maximum_backoffoption to thes3source, which shares the underlyingSqsBackofffactory.Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.