From 424e637b5e7b6030fa8ab69c20b42453dd8d461b Mon Sep 17 00:00:00 2001 From: Dmitri Bourlatchkov Date: Wed, 18 Oct 2023 11:31:19 -0400 Subject: [PATCH] Allow Bigtable RPC retries (#7636) * Allow Bigtable RPC retries Following up on #7552. Add BT total timeout and max attempts settings. Bigtable RPC calls will not be retried if neither total timeout nor max attempts are set. --- .../quarkus/config/QuarkusBigTableConfig.java | 4 ++++ .../providers/storage/BigTableBackendBuilder.java | 2 ++ site/docs/try/configuration.md | 2 ++ .../bigtable/AbstractBigTableBackendTestFactory.java | 9 ++++++++- .../storage/bigtable/BigTableBackendFactory.java | 5 +++++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/servers/quarkus-common/src/main/java/org/projectnessie/quarkus/config/QuarkusBigTableConfig.java b/servers/quarkus-common/src/main/java/org/projectnessie/quarkus/config/QuarkusBigTableConfig.java index ecb85b0cac9..9c835895ad2 100644 --- a/servers/quarkus-common/src/main/java/org/projectnessie/quarkus/config/QuarkusBigTableConfig.java +++ b/servers/quarkus-common/src/main/java/org/projectnessie/quarkus/config/QuarkusBigTableConfig.java @@ -46,8 +46,12 @@ public interface QuarkusBigTableConfig { Optional maxRetryDelay(); + OptionalInt maxAttempts(); + Optional initialRpcTimeout(); + Optional totalTimeout(); + Optional initialRetryDelay(); OptionalInt minChannelCount(); diff --git a/servers/quarkus-common/src/main/java/org/projectnessie/quarkus/providers/storage/BigTableBackendBuilder.java b/servers/quarkus-common/src/main/java/org/projectnessie/quarkus/providers/storage/BigTableBackendBuilder.java index 846af0eabb0..ae5664df9ca 100644 --- a/servers/quarkus-common/src/main/java/org/projectnessie/quarkus/providers/storage/BigTableBackendBuilder.java +++ b/servers/quarkus-common/src/main/java/org/projectnessie/quarkus/providers/storage/BigTableBackendBuilder.java @@ -139,6 +139,8 @@ public Backend buildBackend() { configureDataClient( dataSettings, Optional.of(poolSettings), + bigTableConfig.totalTimeout(), + bigTableConfig.maxAttempts(), bigTableConfig.maxRetryDelay(), bigTableConfig.initialRpcTimeout(), bigTableConfig.initialRetryDelay()); diff --git a/site/docs/try/configuration.md b/site/docs/try/configuration.md index 02bbb35b23c..d2d194ae9cf 100644 --- a/site/docs/try/configuration.md +++ b/site/docs/try/configuration.md @@ -73,6 +73,8 @@ When setting `nessie.version.store.type=BIGTABLE` which enables Google BigTable | `nessie.version.store.persist.bigtable.initial-channel-count` | `1` | `int` | Initial number of gRPC channels. Refer to Google docs for details. | | `nessie.version.store.persist.bigtable.min-rpcs-per-channel` | `0` | `int` | Minimum number of RPCs per channel. Refer to Google docs for details. | | `nessie.version.store.persist.bigtable.max-rpcs-per-channel` | (unlimited) | `int` | Maximum number of RPCs per channel. Refer to Google docs for details. | +| `nessie.version.store.persist.bigtable.max-attempts` | (unspecified) | `int` | Maximum number of attempts for each Bigtable API call (including retries). | +| `nessie.version.store.persist.bigtable.total-timeout` | (unspecified) | `Duration` | Total timeout (including retries) for Bigtable API calls. | | `nessie.version.store.persist.bigtable.initial-rpc-timeout` | (unspecified) | `Duration` | Initial RPC timeout. | | `nessie.version.store.persist.bigtable.initial-retry-delay` | (unspecified) | `Duration` | Initial retry delay. | | `nessie.version.store.persist.bigtable.max-retry-delay` | (unspecified) | `Duration` | Max retry-delay. | diff --git a/versioned/storage/bigtable/src/main/java/org/projectnessie/versioned/storage/bigtable/AbstractBigTableBackendTestFactory.java b/versioned/storage/bigtable/src/main/java/org/projectnessie/versioned/storage/bigtable/AbstractBigTableBackendTestFactory.java index a08823fab69..9a5197c72f4 100644 --- a/versioned/storage/bigtable/src/main/java/org/projectnessie/versioned/storage/bigtable/AbstractBigTableBackendTestFactory.java +++ b/versioned/storage/bigtable/src/main/java/org/projectnessie/versioned/storage/bigtable/AbstractBigTableBackendTestFactory.java @@ -25,6 +25,7 @@ import com.google.common.annotations.VisibleForTesting; import java.io.IOException; import java.util.Optional; +import java.util.OptionalInt; import org.projectnessie.versioned.storage.common.persist.Backend; import org.projectnessie.versioned.storage.testextension.BackendTestFactory; @@ -61,7 +62,13 @@ BigtableDataClient buildNewDataClient() { .setCredentialsProvider(NoCredentialsProvider.create()); configureDataClient( - settings, Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()); + settings, + Optional.empty(), + Optional.empty(), + OptionalInt.empty(), + Optional.empty(), + Optional.empty(), + Optional.empty()); return BigtableDataClient.create(settings.build()); } catch (IOException e) { diff --git a/versioned/storage/bigtable/src/main/java/org/projectnessie/versioned/storage/bigtable/BigTableBackendFactory.java b/versioned/storage/bigtable/src/main/java/org/projectnessie/versioned/storage/bigtable/BigTableBackendFactory.java index c8bd0280b8b..79b0b4947b9 100644 --- a/versioned/storage/bigtable/src/main/java/org/projectnessie/versioned/storage/bigtable/BigTableBackendFactory.java +++ b/versioned/storage/bigtable/src/main/java/org/projectnessie/versioned/storage/bigtable/BigTableBackendFactory.java @@ -23,6 +23,7 @@ import java.time.Duration; import java.util.List; import java.util.Optional; +import java.util.OptionalInt; import java.util.function.Consumer; import javax.annotation.Nonnull; import org.projectnessie.versioned.storage.common.persist.Backend; @@ -56,6 +57,8 @@ public Backend buildBackend(@Nonnull @jakarta.annotation.Nonnull BigTableBackend public static void configureDataClient( BigtableDataSettings.Builder settings, Optional channelPoolSettings, + Optional totalRpcTimeout, + OptionalInt maxAttempts, Optional maxRetryDelay, Optional initialRpcTimeout, Optional initialRetryDelay) { @@ -68,9 +71,11 @@ public static void configureDataClient( stubSettings.mutateRowSettings().retrySettings(), stubSettings.bulkMutateRowsSettings().retrySettings(), stubSettings.readChangeStreamSettings().retrySettings())) { + configureDuration(totalRpcTimeout, retrySettings::setTotalTimeout); configureDuration(initialRpcTimeout, retrySettings::setInitialRpcTimeout); configureDuration(initialRetryDelay, retrySettings::setInitialRetryDelay); configureDuration(maxRetryDelay, retrySettings::setMaxRetryDelay); + maxAttempts.ifPresent(retrySettings::setMaxAttempts); } channelPoolSettings.ifPresent(