Repository navigation
enhancement(aws_sqs source): Adaptive polling concurrency (#13322) - #26920
jimmystewpot wants to merge 7 commits into
Conversation
…_concurrency Signed-off-by: James Lamb <admin@oranged.to>
…ectordotdev#13322) Signed-off-by: James Lamb <admin@oranged.to>
…ctordotdev#13322) Signed-off-by: James Lamb <admin@oranged.to>
…amp parsing Signed-off-by: James Lamb <admin@oranged.to>
…g author Signed-off-by: James Lamb <admin@oranged.to>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
🔵 Needs a closer look
The changes affect concurrent SQS worker lifecycle, cancellation, adaptive scaling, and acknowledgement behavior, requiring runtime and integration validation for race conditions and shutdown under real backpressure.
No open issues 🎉
What changed in this PR
This pull request adds adaptive polling concurrency to the aws_sqs source, reducing unnecessary polling for idle queues while scaling workers based on queue activity.
Changes:
- Added dynamic worker scaling, idle/error scale-down, retry backoff, and sibling cancellation.
- Added
max_concurrencywith deprecatedclient_concurrencycompatibility. - Added unit and integration coverage, safer timestamp parsing, updated documentation, and a changelog entry.
| File | Description |
|---|---|
website/cue/reference/components/sources/generated/aws_sqs.cue |
Updates generated configuration documentation for the new and deprecated concurrency options. |
website/cue/reference/components/sources/aws_sqs.cue |
Documents automatic concurrency management behavior. |
src/sources/aws_sqs/source.rs |
Implements adaptive polling workers, cancellation, backoff, timestamp handling, and related tests. |
src/sources/aws_sqs/integration_tests.rs |
Adds multi-batch ingestion coverage with configured maximum concurrency. |
src/sources/aws_sqs/config.rs |
Adds concurrency configuration, deprecation handling, resolution logic, and validation tests. |
changelog.d/13322_aws_sqs_auto_concurrency.enhancement.md |
Records the user-facing adaptive concurrency enhancement. |
Review effort: Lite
There was a problem hiding this comment.
More details
Static inspection found no actionable defects in adaptive polling, configuration fallback, or sibling cancellation. Runtime behavior remains unverified because tests were inspected but not executed.
🤖 Bits Code Review · Commit e30f623
Summary
This PR introduces adaptive polling concurrency ("auto-concurrency") to the
aws_sqssource to optimise resource utilisation and minimise unnecessaryReceiveMessageAPI requests when an SQS queue is idle or experiencing low traffic.Previously,
aws_sqsinitialised a fixed pool ofclient_concurrencypolling tasks (defaulting to the number of available CPUs) at startup. Because AWS SQS is a pay-per-request service, runningNconcurrent long-polling loops against an idle queue resulted inNcontinuousReceiveMessagecalls everypoll_secsinterval when a single polling task would suffice.With this change:
1..=max_concurrency):SqsSourcestarts with a single active polling worker and dynamically scales up tomax_concurrency(defaulting tocrate::num_threads()) when all active workers observe busy batches (>= 5messages, half ofMAX_BATCH_SIZE = 10to account for standard SQS partition distribution).0messages) or aReceiveMessageerror, surplus workers (concurrency > 1) scale down and exit atomically while guaranteeing the floor worker (concurrency == 1) never exits on idle polls. If the floor worker encounters aReceiveError, it backs off for1s(RECEIVE_ERROR_RETRY_DELAY) inside a cancellableselect!loop to avoid tight retry loops on persistent errors.tokio::sync::watchchannel to broadcast downstreamSourceSenderclosure (PollOutcome::StreamClosed) so sibling workers blocked in long polls abort immediately rather than waiting forpoll_secsto elapse.max_concurrencytoAwsSqsConfigand deprecatesclient_concurrencywith a runtime deprecation warning and fallback whenclient_concurrencyis still configured..expect("invalid timestamp")inget_timestampwith.single()so out-of-range millisecondSentTimestampattributes returnNonerather than panicking, and matches(finalizer, batch_receiver)as a tuple inrun_once.References
Closes: #13322
Related: #13240
Vector configuration
How did you test this PR?
src/sources/aws_sqs/config.rs&src/sources/aws_sqs/source.rs):resolve_max_concurrency()precedence (max_concurrency> deprecatedclient_concurrency>crate::num_threads()) and YAML rejection ofmax_concurrency: 0.#[tokio::test(start_paused = true)]) covering single-worker startup, scale-up tomax_concurrencyon busy batches, steady-state behaviour on partial batches (1..=4messages), scale-down to1on empty polls, floor-worker backoff onReceiveError, re-scaling after scale-down, immediate cancellation of in-flight sibling workers onStreamClosed,max_concurrency = 1upper-bound enforcement, and worker panic propagation.get_timestampsafely ignores non-numeric and out-of-range (i64::MAX) timestamps.cargo nextest run --no-default-features --features sources-aws_sqs -E 'test(sources::aws_sqs)'(19/19 passing).src/sources/aws_sqs/integration_tests.rs):test_max_concurrency_delivers_multiple_batchesto verify multi-batch ingestion withmax_concurrencyconfigured.FEATURES="sources-aws_sqs,aws-sqs-integration-tests" make check-clippymake check-fmtmake check-generated-docsmake check-changelog-fragmentsmake check-markdownDoes this PR include user facing changes?
no-changeloglabel to this PR.Contributor Guidelines
@vectordotdev/vectorto reach out to us regarding this PR.git merge origin masterandgit push.