8000 refactor(inkless:s3): enable adaptive retry mode by jeqo · Pull Request #442 · aiven/inkless · GitHub
[go: up one dir, main page]

Skip to content

refactor(inkless:s3): enable adaptive retry mode - #442

Merged
jjaakola-aiven merged 1 commit into
mainfrom
jeqo/s3-adaptive-retry
Oct 31, 2025
Merged

jjaakola-aiven merged 1 commit into
mainfrom
jeqo/s3-adaptive-retry

Conversation

@jeqo
@jeqo jeqo commented Oct 23, 2025 •
Copy link
Copy Markdown
Contributor

This mode shows better performance under concurrent, high-troughput scenarios by accommodating request rates to cope with the throughput needed.

It goes from unpredictable rates
image
which lead to unpredictable latency:
image

To a much more stable rate based on throughput
image
Leading to more stable latencies
image

This is a bit counterintuitive as the docs say:

Adaptive V2 retry mode is not recommended when predictable latency is important.

But for predictable performance in this concurrent environment it seems to play better. We can make it configurable if it degrades performance for certain workloads.

@jeqo
jeqo force-pushed the jeqo/s3-adaptive-retry branch 3 times, most recently from f3c3479 to 8b15ec8 Compare October 28, 2025 19:13
@jeqo
jeqo changed the base branch from main to jeqo/fix-closing-storages October 28, 2025 19:13
@jeqo
jeqo force-pushed the jeqo/fix-closing-storages branch 4 times, most recently from 4c44c50 to 48a6c85 Compare October 29, 2025 15:47
Base automatically changed from jeqo/fix-closing-storages to main October 30, 2025 15:37
This mode shows better performance under concurrent, high-troughput
scenarios by accommodating request rates to cope with the throughput
needed.
@jeqo
jeqo force-pushed the jeqo/s3-adaptive-retry branch from 8b15ec8 to cdd58d6 Compare October 30, 2025 15:40
@jeqo
jeqo marked this pull request as ready for review October 30, 2025 16:00
@jjaakola-aiven
jjaakola-aiven merged commit 5875f03 into main Oct 31, 2025
@jjaakola-aiven
jjaakola-aiven deleted the jeqo/s3-adaptive-retry branch October 31, 2025 07:01
jeqo added a commit that referenced this pull request Oct 31, 2025
This mode shows better performance under concurrent, high-troughput
scenarios by accommodating request rates to cope with the throughput
needed.
jeqo added a commit that referenced this pull request Nov 28, 2025
This mode shows better performance under concurrent, high-troughput
scenarios by accommodating request rates to cope with the throughput
needed.
jeqo added a commit that referenced this pull request Nov 30, 2026
With a bounded `s3.api.call.timeout` (default 2000 ms), the AWS SDK `ADAPTIVE_V2` client-side token bucket can enter a self-sustaining lockout after S3 throttling. Once a throttling response sets `enabled = true` on `RateLimiterTokenBucket`, that flag never resets. If a throttling burst or a quiet period drops `fillRate` below concurrent request demand, callers subtract tokens into negative capacity and sleep in `RetryableStage2` past `apiCallTimeout`. Timed-out calls fail before sending an HTTP attempt, never refund their tokens, and never deliver the successful response required for CUBIC recovery, so the client stays stuck until broker restart. Current upstream AWS SDK v2 releases still queue timed-out sync waiters without skipping cancelled futures in `RateLimiterTokenBucket.doNotify()`.

`ADAPTIVE_V2` was enabled in #442 when `s3.api.call.timeout` defaulted to unbounded (`null`) and hot and cold reads shared one fetch client. Later changes split out a dedicated cold-path client (#562, which sees idle gaps between bursts that drag `fillRate` down via `2 * measuredTxRate`) and set the default `s3.api.call.timeout` to 2000 ms (#791), exposing the lockout cliff. AWS SDK Javadoc also cautions against `ADAPTIVE_V2` when predictable latency matters or a single client serves multiple resources, and upstream AWS SDK v2 now defaults to `STANDARD`.

Add `s3.retry.mode` (valid values `standard` and `adaptive_v2`, case-insensitive) to `S3StorageConfig`, wire it in `S3ClientBuilder`, and switch the default to `standard`. `STANDARD` keeps jittered exponential backoff and the SDK retry quota circuit breaker without the client-side rate limiter. Per-role overrides (such as `inkless.storage.fetch.s3.retry.mode`) work through the existing `InklessConfig` role layering.

Add `S3ThrottlingRecoveryTest` to verify concurrent fetches recover after `503 SlowDown` throttling with the default mode and that pre-attempt timeouts with `adaptive_v2` increment `configured-timeout-errors`.

Assisted-by: Gemini 4 Neon
jeqo added a commit that referenced this pull request Dec 1, 2026
…call-level timeouts [KC-874] (#915)

* fix(inkless:s3): record call-level timeouts in S3 metrics

`MetricCollector.publish()` reads `CoreMetric.ERROR_TYPE` only from `ApiCallAttempt` child collections. Because `ApiCallTimeoutTrackingStage` wraps `ApiCallAttemptMetricCollectionStage` in the AWS SDK sync pipeline, an `ApiCallTimeoutException` never appears on an attempt child. When a call times out before an HTTP attempt starts (such as during a backoff or rate-limiter wait) or while an attempt is in flight, `configured-timeout-errors` stays at zero even though requests time out.

Have `MetricCollector` implement `ExecutionInterceptor` and register it on the S3 client in `S3ClientBuilder`. On `onExecutionFailure`, record `CONFIGURED_TIMEOUT` globally and per operation when the failure is an `ApiCallTimeoutException`. Attempt-level `ApiCallAttemptTimeoutException` failures stay handled by `publish()` without double counting.

Assisted-by: Gemini 4 Neon

* fix(inkless:s3): default S3 retry mode to standard and add s3.retry.mode

With a bounded `s3.api.call.timeout` (default 2000 ms), the AWS SDK `ADAPTIVE_V2` client-side token bucket can enter a self-sustaining lockout after S3 throttling. Once a throttling response sets `enabled = true` on `RateLimiterTokenBucket`, that flag never resets. If a throttling burst or a quiet period drops `fillRate` below concurrent request demand, callers subtract tokens into negative capacity and sleep in `RetryableStage2` past `apiCallTimeout`. Timed-out calls fail before sending an HTTP attempt, never refund their tokens, and never deliver the successful response required for CUBIC recovery, so the client stays stuck until broker restart. Current upstream AWS SDK v2 releases still queue timed-out sync waiters without skipping cancelled futures in `RateLimiterTokenBuc
8747
ket.doNotify()`.

`ADAPTIVE_V2` was enabled in #442 when `s3.api.call.timeout` defaulted to unbounded (`null`) and hot and cold reads shared one fetch client. Later changes split out a dedicated cold-path client (#562, which sees idle gaps between bursts that drag `fillRate` down via `2 * measuredTxRate`) and set the default `s3.api.call.timeout` to 2000 ms (#791), exposing the lockout cliff. AWS SDK Javadoc also cautions against `ADAPTIVE_V2` when predictable latency matters or a single client serves multiple resources, and upstream AWS SDK v2 now defaults to `STANDARD`.

Add `s3.retry.mode` (valid values `standard` and `adaptive_v2`, case-insensitive) to `S3StorageConfig`, wire it in `S3ClientBuilder`, and switch the default to `standard`. `STANDARD` keeps jittered exponential backoff and the SDK retry quota circuit breaker without the client-side rate limiter. Per-role overrides (such as `inkless.storage.fetch.s3.retry.mode`) work through the existing `InklessConfig` role layering.

Add `S3ThrottlingRecoveryTest` to verify concurrent fetches recover after `503 SlowDown` throttling with the default mode and that pre-attempt timeouts with `adaptive_v2` increment `configured-timeout-errors`.

Assisted-by: Gemini 4 Neon

* fixup! fix(inkless:s3): record call-level timeouts in S3 metrics

Assisted-by: Gemini 4 Neon
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

0