Skip to content

add spring-ydb-retry module#216

Merged
KirillKurdyukov merged 11 commits into
ydb-platform:mainfrom
karambo3a:spring-ydb-retry
May 28, 2026
Merged

add spring-ydb-retry module#216
KirillKurdyukov merged 11 commits into
ydb-platform:mainfrom
karambo3a:spring-ydb-retry

Conversation

@karambo3a

@karambo3a karambo3a commented May 7, 2026

Copy link
Copy Markdown
Contributor

add a new spring-ydb-retry module with Spring Boot auto-configuration for retrying YDB transactional methods on retryable status codes.

Comment thread spring-ydb/spring-ydb-retry/src/main/java/tech/ydb/retry/YdbDelayCalculator.java Outdated
@robot-vibe-db

robot-vibe-db Bot commented May 7, 2026

Copy link
Copy Markdown

AI Review Summary

Verdict: ✅ No critical issues found

Critical issues

No critical issues found.

Other findings

  • Minor | Medium: First retry always uses zero backoff delay — even for OVERLOADED / CLIENT_RESOURCE_EXHAUSTED status codes that use slow backoff, the first retry fires immediately — YdbDelayCalculator.java:28
  • Minor | High: @YdbTransactional(maxRetries = 0) passes checkCandidate but then throws IllegalArgumentException in the constructor. Users wanting to disable retries per-method should use enabled = false, but this is not documented — YdbRetryPolicyConfig.java:110
  • Minor | High: calculate() calls overallLatenciesSnapshot() 3× (and similarly for read/write), each creating a full copy + sort. 9 redundant copies+sorts of potentially large lists — SloStats.java:132
  • Minor | Medium: Executors.newFixedThreadPool(20) with unbounded queue could accumulate tasks during chaos tests if operations slow down — SloRunner.java:161
  • Minor | Low: DeterministicErrorChannel uses static mutable state (rules, counters) shared across all tests — fragile if tests ever run in parallel — DeterministicErrorChannel.java:31
  • Nit | High: Unreachable throw new IllegalStateException("retry loop finished unexpectedly") — the for loop always returns or throws — YdbTransactionInterceptor.java:86

This review was generated automatically. Critical issues require attention; other findings are advisory.
If this comment was useful, please give it a 👍 — it helps us improve the review bot.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new spring-ydb-retry module to the spring-ydb multi-module build, providing Spring Boot auto-configuration that replaces Spring’s default transactionInterceptor with a YDB-aware interceptor that retries transactional work on retryable YDB status codes (with configurable backoff and idempotency).

Changes:

  • Introduces spring-ydb-retry runtime code: @YdbTransactional, retry policy/config, delay calculator, and an auto-configuration that swaps in YdbTransactionInterceptor.
  • Adds extensive unit tests plus Docker/Testcontainers-style integration tests using a deterministic gRPC error injector to validate retry semantics.
  • Adds an SLO workload app + Docker Compose “chaos” playground to compare retry vs no-retry behavior under injected cluster/node failures.

Reviewed changes

Copilot reviewed 69 out of 69 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
spring-ydb/pom.xml Registers spring-ydb-retry as a module in the spring-ydb aggregator.
spring-ydb/spring-ydb-retry/pom.xml Defines dependencies/build for the new retry module + test stack.
spring-ydb/spring-ydb-retry/README.md Documents library purpose, installation, and configuration properties.
spring-ydb/spring-ydb-retry/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports Registers YdbTransactionAutoConfiguration for Spring Boot auto-config import.
spring-ydb/spring-ydb-retry/src/main/java/tech/ydb/retry/BackoffSleeper.java Abstraction for sleeping between retries (testable).
spring-ydb/spring-ydb-retry/src/main/java/tech/ydb/retry/YdbDelayCalculator.java Implements per-status backoff + jitter calculation.
spring-ydb/spring-ydb-retry/src/main/java/tech/ydb/retry/YdbRetryPolicy.java Central “should retry” decision based on YDB status code/idempotency.
spring-ydb/spring-ydb-retry/src/main/java/tech/ydb/retry/YdbRetryPolicyConfig.java Config object + merge logic for global + annotation overrides.
spring-ydb/spring-ydb-retry/src/main/java/tech/ydb/retry/YdbRetryProperties.java Spring Boot @ConfigurationProperties binding for global retry config.
spring-ydb/spring-ydb-retry/src/main/java/tech/ydb/retry/YdbTransactional.java @Transactional alias annotation with extra retry settings.
spring-ydb/spring-ydb-retry/src/main/java/tech/ydb/retry/YdbTransactionAutoConfiguration.java Boot auto-config that registers the bean-definition replacer.
spring-ydb/spring-ydb-retry/src/main/java/tech/ydb/retry/YdbTransactionInterceptor.java Transaction interceptor that wraps transactional execution with YDB retry.
spring-ydb/spring-ydb-retry/src/main/java/tech/ydb/retry/YdbTransactionInterceptorFactory.java FactoryBean that creates/configures YdbTransactionInterceptor.
spring-ydb/spring-ydb-retry/src/main/java/tech/ydb/retry/YdbTransactionInterceptorReplacer.java Registry post-processor that replaces transactionInterceptor bean definition.
spring-ydb/spring-ydb-retry/src/test/resources/application-disabled.properties Test profile for globally disabled retry.
spring-ydb/spring-ydb-retry/src/test/resources/application-enabled.properties Test profile for globally enabled retry + tuned backoff caps/bases.
spring-ydb/spring-ydb-retry/src/test/resources/application-ydb.properties Test profile for YDB JDBC connection settings.
spring-ydb/spring-ydb-retry/src/test/resources/db/migration/V1__create_table.sql Flyway migration for integration-test table schema.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/InterceptorTestSupport.java Test harness for invoking the interceptor and simulating outcomes.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/TransactionPropagationRetryTest.java Tests retry behavior when participating in an outer Spring transaction.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/TransactionalDefaultRetryTest.java Tests default retry behavior for plain @Transactional methods.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/YdbDelayCalculatorTest.java Unit tests for backoff/jitter math.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/YdbRetryPolicyConfigTest.java Unit tests for config defaults/validation/merge behavior.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/YdbRetryPolicyTest.java Unit tests for retryability classification by status code/idempotency.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/YdbTransactionInterceptorFactoryTest.java Tests for interceptor factory creation behavior.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/YdbTransactionInterceptorReplacerTest.java Tests bean-definition replacement behavior/metadata preservation.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/YdbTransactionManagerResolutionTest.java Tests transaction manager selection (single/multi/primary/configurer).
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/YdbTransactionalConfigOverrideTest.java Tests per-method overrides via @YdbTransactional.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/integration/YdbIntegrationTest.java Integration-test meta-annotation (tag + shared resource lock).
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/integration/YdbDockerTest.java Base class wiring a shared YDB test environment + dynamic datasource URL.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/integration/IntegrationEnvironmentTest.java Validates Docker/Testcontainers availability for integration tests.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/integration/DeterministicErrorChannel.java gRPC interceptor to inject deterministic YDB status responses.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/integration/DeterministicErrorChannelTest.java Tests deterministic error-channel configuration/validation.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/integration/HappyPathIntegrationTest.java Baseline integration tests for CRUD behavior with retry enabled.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/integration/ExecuteQueryRetryIntegrationTest.java Integration tests for retry behavior on executeQuery failures.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/integration/CommitTransactionRetryTest.java Integration tests for retry behavior on commit failures.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/integration/CombinedErrorIntegrationTest.java Integration tests combining executeQuery + commit error scenarios.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/integration/NonRetryableCommitIntegrationTest.java Ensures non-retryable commit errors are not retried.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/integration/IdempotentRetryIntegrationTest.java Validates idempotent-only retry rules for select status codes.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/integration/DisabledRetryIntegrationTest.java Validates behavior when retry is globally disabled.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/integration/MaxRetriesExhaustedTest.java Integration tests for max-retries exhaustion and success-on-last-attempt.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/integration/ConcurrentRunner.java Test helper to execute concurrent tasks and collect failures.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/integration/ConcurrentWriteIntegrationTest.java Concurrency-focused integration tests (writes + conflict resolution).
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/integration/app/UserApplication.java Minimal Spring Boot app for integration-test wiring.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/integration/app/UserService.java Service methods annotated with @YdbTransactional for integration tests.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/integration/app/User.java Spring Data JDBC entity for integration tests.
spring-ydb/spring-ydb-retry/src/test/java/tech/ydb/retry/integration/app/SimpleUserRepository.java Spring Data JDBC repository + custom update query.
spring-ydb/spring-ydb-retry/slo/pom.xml Standalone SLO workload app build (Boot 3.4 + OTel + spring-ydb-retry).
spring-ydb/spring-ydb-retry/slo/Dockerfile Builds/runs the SLO workload app container image.
spring-ydb/spring-ydb-retry/slo/README.md Docs for SLO testing setup and interpretation.
spring-ydb/spring-ydb-retry/slo/src/README.md Workload application documentation (usage/config/metrics/classes).
spring-ydb/spring-ydb-retry/slo/src/main/resources/application.properties SLO app config defaults/env var bindings for datasource/retry/workload.
spring-ydb/spring-ydb-retry/slo/src/main/java/tech/ydb/slo/SloApplication.java SLO workload Spring Boot entry point.
spring-ydb/spring-ydb-retry/slo/src/main/java/tech/ydb/slo/SloConfig.java Binds SLO workload parameters (@ConfigurationProperties).
spring-ydb/spring-ydb-retry/slo/src/main/java/tech/ydb/slo/OtelConfig.java OTel SDK + Prometheus exporter server configuration.
spring-ydb/spring-ydb-retry/slo/src/main/java/tech/ydb/slo/SloService.java JDBC workload operations annotated with @YdbTransactional.
spring-ydb/spring-ydb-retry/slo/src/main/java/tech/ydb/slo/SloRunner.java Workload runner: table create, seed, run traffic, record metrics.
spring-ydb/spring-ydb-retry/slo/src/main/java/tech/ydb/slo/SloStats.java Tracks success/failure + latency distributions for summary writing.
spring-ydb/spring-ydb-retry/slo/src/main/java/tech/ydb/slo/SloResultWriter.java Coordinates shared runId + writes result summaries to disk.
spring-ydb/spring-ydb-retry/slo/playground/README.md Docs for Docker Compose playground scenarios.
spring-ydb/spring-ydb-retry/slo/playground/configs/ydb.yaml YDB cluster config used by playground environments.
spring-ydb/spring-ydb-retry/slo/playground/configs/prometheus/prometheus.yaml Prometheus scrape configuration for both SLO app instances.
spring-ydb/spring-ydb-retry/slo/playground/configs/grafana/provisioning/datasources/datasource.yaml Grafana datasource provisioning for Prometheus.
spring-ydb/spring-ydb-retry/slo/playground/configs/grafana/provisioning/dashboards/dashboard.yaml Grafana dashboard provisioning configuration.
spring-ydb/spring-ydb-retry/slo/playground/configs/grafana/provisioning/dashboards/slo.json Prebuilt Grafana dashboard for retry vs no-retry comparison.
spring-ydb/spring-ydb-retry/slo/playground/chaos/compose.yaml Baseline chaos Compose environment (YDB cluster + apps + monitoring).
spring-ydb/spring-ydb-retry/slo/playground/chaos/chaos.sh Baseline chaos script (stop/start/restart/kill nodes).
spring-ydb/spring-ydb-retry/slo/playground/chaos-aggressive/compose.yaml Aggressive chaos Compose environment with resource limits.
spring-ydb/spring-ydb-retry/slo/playground/chaos-aggressive/chaos.sh Aggressive chaos script (pause/unpause, multi-kill, rapid cycles).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@KirillKurdyukov KirillKurdyukov enabled auto-merge (squash) May 28, 2026 14:10
@KirillKurdyukov KirillKurdyukov merged commit 0fed2be into ydb-platform:main May 28, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants