Repository navigation
fix(inkless:s3): switch default S3 retry mode to standard and record call-level timeouts [KC-874] - #915
Conversation
`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
There was a problem hiding this comment.
🟡 Changes recommended
The test’s timeout assertions can pass using counts from the initial fetch, leaving the concurrent pre-attempt timeout behavior unverified.
1 open issue
What changed in this PR
This PR addresses S3 read stalls after throttling in Inkless by switching the default retry mode to STANDARD and making call-level timeouts visible in existing metrics.
Changes:
- Add case-insensitive
s3.retry.modeconfiguration withstandardas the default andadaptive_v2as an option. - Record call-level timeouts globally and per operation through an execution interceptor.
- Add unit and integration coverage for retry configuration, timeout metrics, and throttling recovery.
| File | Description |
|---|---|
storage/inkless/src/test/java/io/aiven/inkless/storage_backend/s3/S3StorageConfigTest.java |
Test retry-mode defaults and validation. |
storage/inkless/src/test/java/io/aiven/inkless/storage_backend/s3/S3ClientBuilderTest.java |
Check retry strategy and interceptor wiring. |
storage/inkless/src/test/java/io/aiven/inkless/storage_backend/s3/MetricCollectorTest.java |
Test call-timeout recording and attempt-timeout filtering. |
storage/inkless/src/test/java/io/aiven/inkless/storage_backend/s3/integration/S3ThrottlingRecoveryTest.java |
Add concurrent recovery and pre-attempt timeout scenarios. |
storage/inkless/src/test/java/io/aiven/inkless/storage_backend/s3/integration/S3ErrorMetricsTest.java |
Add call-level timeout metric assertions. |
storage/inkless/src/main/java/io/aiven/inkless/storage_backend/s3/S3StorageConfig.java |
Define and parse the retry-mode setting. |
storage/inkless/src/main/java/io/aiven/inkless/storage_backend/s3/S3ClientBuilder.java |
Apply the configured retry mode and register the interceptor. |
storage/inkless/src/main/java/io/aiven/inkless/storage_backend/s3/MetricCollector.java |
Capture call-level timeout failures in error metrics. |
docs/inkless/configs.rst |
Document retry-mode options and the default. |
Review effort: Balanced
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
c8e2211 to
b15b59d
Compare
There was a problem hiding this comment.
Just had one minor comment to this.
| // ApiCallTimeoutTrackingStage wraps ApiCallAttemptMetricCollectionStage, so an | ||
| // ApiCallTimeoutException never appears on an ApiCallAttempt child. Record it here so | ||
| // call-level timeouts (including waits before any HTTP attempt starts) remain visible. | ||
| if (context.exception() instanceof ApiCallTimeoutException) { |
There was a problem hiding this comment.
"When the call timeout fires mid-attempt, the attempt child already records OTHER via publish() (line 371), so this call now counts in both other-errors and configured-timeout-errors.
There was a problem hiding this comment.
Good catch! TimeoutExceptionHandlingStage throws a raw InterruptedException on mid-attempt call timeouts, so the SDK attempt stage records OTHER.
Instead of suppressing this which would require ThreadLocal mechanism to bridge onExecutionFailure to publish, I'm documenting this double-counting to keep the interceptor stateless. Last fixup commit is updating docs and testing for this.
Assisted-by: Gemini 4 Neon

Brokers using the AWS SDK
ADAPTIVE_V2retry mode with a boundeds3.api.call.timeout(default 2000 ms) can lock up an S3 client until restart after throttling, whileconfigured-timeout-errorsstays at zero. Once a throttling response setsenabled = trueon the SDK'sRateLimiterTokenBucket, that flag never resets: either a throttling burst or a quiet period on a bursty client (which capsfillRateat2 * measuredTxRate) can push token-bucket sleep times pastapiCallTimeout, so every call fails withApiCallTimeoutExceptionbefore sending an HTTP attempt and never delivers the successful response required for CUBIC recovery. BecauseApiCallTimeoutTrackingStagewrapsApiCallAttemptMetricCollectionStage, those pre-attempt timeouts produce noApiCallAttemptchild and only report booleanAPI_CALL_SUCCESSFUL = falseon the root collection, leavingMetricCollector.publish()blind to them. Switching the default retry mode toSTANDARDremoves the client-side token bucket while keeping identical retry limits, backoff, and circuit-breaker protection, and registeringMetricCollectoras anExecutionInterceptorsurfaces call-levelApiCallTimeoutExceptionfailures inconfigured-timeout-errors.Commits
fix(inkless:s3): record call-level timeouts in S3 metricsfix(inkless:s3): default S3 retry mode to standard and add s3.retry.modeSee the commit messages for the reasoning behind each step (including why
#442→#562→#791exposed the lockout and why current upstream AWS SDK v2 releases still queue timed-out sync waiters inRateLimiterTokenBucket.doNotify()).Configuration and operator impact
s3.retry.mode(underinkless.storage.): valid valuesstandardandadaptive_v2(case-insensitive), defaultstandard. Supports per-role overrides throughinkless.storage.<role>.s3.retry.mode(for example, optingbackgroundback intoadaptive_v2if needed) and is documented indocs/inkless/configs.rst.ADAPTIVE_V2→STANDARD): max attempts (3), non-throttle exponential backoff (100 ms base, 20 s max), throttling exponential backoff (1 s base, 20 s max), retryable error predicates, and the retry-quota circuit breaker (500 tokens, cost 5 per retry including throttles, +1 per success) remain identical. Only the pre-attempt client-side CUBIC token bucket is removed; first attempts no longer sleep before HTTP transmission, while concurrency and rate stay bounded by Inkless's thread pools and optionalfetch.lagging.consumer.request.rate.limit.configured-timeout-errors-rateandconfigured-timeout-errors-total(global and per-operation, updated indocs/inkless/metrics.rst) now include call-levelApiCallTimeoutExceptionfailures viaExecutionInterceptor.onExecutionFailure()in addition to attempt-level timeouts. When a call timeout fires mid-attempt, AWS SDK's attempt stage also recordsOTHERfor the interrupted attempt; keeping the interceptor stateless accepts that SDK quirk (dashboards do not sumother-errorsandconfigured-timeout-errors) rather than bridging topublish()with aThreadLocal. Existing latency metrics (*-time-avg/*-time-max, backed byAPI_CALL_DURATION) are unchanged and already include wait time and timed-out calls.Test plan
S3ThrottlingRecoveryTest(new WireMock integration suite): pins concurrent fetch recovery after503 SlowDownthrottling with the defaultstandardmode (reproduces a permanent timeout stall onadaptive_v2) and verifies under explicitadaptive_v2that concurrent pre-attempt timeouts increment both global andoperation="GetObject"configured-timeout-errors-totalby the exact observed delta above post-arming baselines while fewer HTTP requests reach WireMock than timeouts occurred.S3ErrorMetricsTest: adds an integration test verifying call-levelApiCallTimeoutExceptionupdates global and per-operationconfigured-timeout-errors.MetricCollectorTest,S3StorageConfigTest, and 8000S3ClientBuilderTest: unit tests coveringonExecutionFailurefiltering (no double counting ofApiCallAttemptTimeoutException),s3.retry.modevalidation, and builder wiring for both retry modes and the execution interceptor.