From 9cc5e23eae0a1cbd571457e2b09a11572bb4faf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Olav=20L=C3=B8ite?= Date: Wed, 26 May 2021 10:43:18 +0200 Subject: [PATCH 1/2] docs: document retry settings in sample --- .../CustomTimeoutAndRetrySettingsExample.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/samples/snippets/src/main/java/com/example/spanner/CustomTimeoutAndRetrySettingsExample.java b/samples/snippets/src/main/java/com/example/spanner/CustomTimeoutAndRetrySettingsExample.java index ad3fb8067c..6d2374b2f1 100644 --- a/samples/snippets/src/main/java/com/example/spanner/CustomTimeoutAndRetrySettingsExample.java +++ b/samples/snippets/src/main/java/com/example/spanner/CustomTimeoutAndRetrySettingsExample.java @@ -53,14 +53,23 @@ static void executeSqlWithCustomTimeoutAndRetrySettings( .setRetrySettings( RetrySettings.newBuilder() // Configure retry delay settings. + // The initial amount of time to wait before retrying the request. .setInitialRetryDelay(Duration.ofMillis(500)) - .setMaxRetryDelay(Duration.ofSeconds(64)) + // The maximum amount of time to wait before retrying. I.e. after this value is + // reached, the wait time will not increase further by the multiplier. + .setMaxRetryDelay(Duration.ofSeconds(10)) + // The previous wait time is multiplied by this multiplier to come up with the next + // wait time, until the max is reached. .setRetryDelayMultiplier(1.5) // Configure RPC and total timeout settings. - .setInitialRpcTimeout(Duration.ofSeconds(60)) - .setMaxRpcTimeout(Duration.ofSeconds(60)) - .setRpcTimeoutMultiplier(1.0) + // Timeout for the first RPC call. Subsequent retries will be based off this value. + .setInitialRpcTimeout(Duration.ofSeconds(5)) + // The max for the per RPC timeout. + .setMaxRpcTimeout(Duration.ofSeconds(30)) + // Controls the change of timeout for each retry. + .setRpcTimeoutMultiplier(1.5) + // The timeout for all calls (first call + all retries). .setTotalTimeout(Duration.ofSeconds(60)) .build()); // Create a Spanner client using the custom retry and timeout settings. From c573c62468a6622998baa88d017fc7ce10ccddb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Olav=20L=C3=B8ite?= Date: Wed, 26 May 2021 13:01:06 +0200 Subject: [PATCH 2/2] fix: change timeout values back to match doc --- .../spanner/CustomTimeoutAndRetrySettingsExample.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/snippets/src/main/java/com/example/spanner/CustomTimeoutAndRetrySettingsExample.java b/samples/snippets/src/main/java/com/example/spanner/CustomTimeoutAndRetrySettingsExample.java index 6d2374b2f1..e3e5187514 100644 --- a/samples/snippets/src/main/java/com/example/spanner/CustomTimeoutAndRetrySettingsExample.java +++ b/samples/snippets/src/main/java/com/example/spanner/CustomTimeoutAndRetrySettingsExample.java @@ -57,18 +57,18 @@ static void executeSqlWithCustomTimeoutAndRetrySettings( .setInitialRetryDelay(Duration.ofMillis(500)) // The maximum amount of time to wait before retrying. I.e. after this value is // reached, the wait time will not increase further by the multiplier. - .setMaxRetryDelay(Duration.ofSeconds(10)) + .setMaxRetryDelay(Duration.ofSeconds(64)) // The previous wait time is multiplied by this multiplier to come up with the next // wait time, until the max is reached. .setRetryDelayMultiplier(1.5) // Configure RPC and total timeout settings. // Timeout for the first RPC call. Subsequent retries will be based off this value. - .setInitialRpcTimeout(Duration.ofSeconds(5)) + .setInitialRpcTimeout(Duration.ofSeconds(60)) // The max for the per RPC timeout. - .setMaxRpcTimeout(Duration.ofSeconds(30)) + .setMaxRpcTimeout(Duration.ofSeconds(60)) // Controls the change of timeout for each retry. - .setRpcTimeoutMultiplier(1.5) + .setRpcTimeoutMultiplier(1.0) // The timeout for all calls (first call + all retries). .setTotalTimeout(Duration.ofSeconds(60)) .build());