Skip to content

Commit

Permalink
docs: update custom retry and timeout sample (#2340)
Browse files Browse the repository at this point in the history
Fixes a couple of minor issues in the retry- and timeout sample:
1. Remove `DeadlineExceeded` as a retryable code, as the sample uses a
single timeout will not retry on `DeadlineExceeded` anyways, meaning
that the addition of that error code was just confusing.
2. Update the `maxBackoff` to 16 seconds. It was currently 6400ms, which
was a typo, as all the other client libraries used 64s. That was also
the value that was mentioned in the documentation page that imports this
sample, meaning that there was a discrepancy between the documentation
and the sample. We are setting this value to 16 seconds for all client
libraries, as it makes the sample confusing when the max backoff is
larger than the total timeout (60 seconds).

The documentation page that uses this sample is
https://cloud.google.com/spanner/docs/custom-timeout-and-retry#c
  • Loading branch information
olavloite authored Sep 28, 2023
1 parent 714acd6 commit 639f2e0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions spanner/api/Spanner.Samples/CustomTimeoutsAndRetriesAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ public async Task<long> CustomTimeoutsAndRetriesAsync(string projectId, string i
.WithRetry(RetrySettings.FromExponentialBackoff(
maxAttempts: 12,
initialBackoff: TimeSpan.FromMilliseconds(500),
maxBackoff: TimeSpan.FromMilliseconds(6400),
maxBackoff: TimeSpan.FromSeconds(16),
backoffMultiplier: 1.5,
retryFilter: RetrySettings.FilterForStatusCodes(
new StatusCode[] { StatusCode.Unavailable, StatusCode.DeadlineExceeded })));
new StatusCode[] { StatusCode.Unavailable })));

ResultSet result = await session.ExecuteSqlAsync(request, settings);
await session.CommitAsync(new CommitRequest(), null);
Expand Down

0 comments on commit 639f2e0

Please sign in to comment.