Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: reduce the probability of RESOURCE_EXHAUSTED errors during tests (…
…#734) * fix: reduce the probability of RESOURCE_EXHAUSTED errors during tests Reduces the probability of RESOURCE_EXHAUSTED errors during tests by making the GetOperation method retry errors with this code with an exponential backoff. The GetOperation method is called repeatedly for long-running operations by a polling future. These calls also count towards the max 5 admin requests per second. Fixes #733 * fix: use default retry settings * chore: run formatter * fix: only retry RESOURCE_EXHAUSTED when throttling requests
- Loading branch information
Showing
2 changed files
with
95 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
.../java/com/google/cloud/spanner/spi/v1/GrpcDatabaseAdminStubWithCustomCallableFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2020 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.cloud.spanner.spi.v1; | ||
|
||
import com.google.api.gax.grpc.GrpcStubCallableFactory; | ||
import com.google.api.gax.rpc.ClientContext; | ||
import com.google.api.gax.rpc.StatusCode; | ||
import com.google.cloud.spanner.admin.database.v1.stub.DatabaseAdminStubSettings; | ||
import com.google.cloud.spanner.admin.database.v1.stub.GrpcDatabaseAdminStub; | ||
import java.io.IOException; | ||
|
||
/** | ||
* Wrapper around {@link GrpcDatabaseAdminStub} to make the constructor available inside this | ||
* package. This makes it possible to create a {@link GrpcDatabaseAdminStub} with a custom {@link | ||
* GrpcStubCallableFactory} and custom settings. This is used by integration tests to automatically | ||
* retry {@link StatusCode.Code#RESOURCE_EXHAUSTED} errors for certain administrative requests. | ||
*/ | ||
class GrpcDatabaseAdminStubWithCustomCallableFactory extends GrpcDatabaseAdminStub { | ||
GrpcDatabaseAdminStubWithCustomCallableFactory( | ||
DatabaseAdminStubSettings settings, | ||
ClientContext clientContext, | ||
GrpcStubCallableFactory callableFactory) | ||
throws IOException { | ||
super(settings, clientContext, callableFactory); | ||
} | ||
} |