Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ implementation 'com.google.cloud:google-cloud-spanner'
If you are using Gradle without BOM, add this to your dependencies:

```Groovy
implementation 'com.google.cloud:google-cloud-spanner:6.42.2'
implementation 'com.google.cloud:google-cloud-spanner:6.42.3'
```

If you are using SBT, add this to your dependencies:

```Scala
libraryDependencies += "com.google.cloud" % "google-cloud-spanner" % "6.42.2"
libraryDependencies += "com.google.cloud" % "google-cloud-spanner" % "6.42.3"
```
<!-- {x-version-update-end} -->

Expand Down Expand Up @@ -412,7 +412,7 @@ Java is a registered trademark of Oracle and/or its affiliates.
[kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-spanner/java11.html
[stability-image]: https://img.shields.io/badge/stability-stable-green
[maven-version-image]: https://img.shields.io/maven-central/v/com.google.cloud/google-cloud-spanner.svg
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-spanner/6.42.2
[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-spanner/6.42.3
[authentication]: https://github.com/googleapis/google-cloud-java#authentication
[auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes
[predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -993,13 +993,26 @@ public Builder setAutoThrottleAdministrativeRequests() {
return this;
}

/**
* Disables automatic retries of administrative requests that fail if the <a
* href="https://cloud.google.com/spanner/quotas#administrative_limits">https://cloud.google.com/spanner/quotas#administrative_limits</a>
* have been exceeded. You should disable these retries if you intend to handle these errors in
* your application.
*/
public Builder disableAdministrativeRequestRetries() {
this.retryAdministrativeRequestsSettings =
this.retryAdministrativeRequestsSettings.toBuilder().setMaxAttempts(1).build();
return this;
}

/**
* Sets the retry settings for retrying administrative requests when the quote of administrative
* requests per minute has been exceeded.
*/
Builder setRetryAdministrativeRequestsSettings(
RetrySettings retryAdministrativeRequestsSettings) {
this.retryAdministrativeRequestsSettings = retryAdministrativeRequestsSettings;
this.retryAdministrativeRequestsSettings =
Preconditions.checkNotNull(retryAdministrativeRequestsSettings);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -935,4 +935,31 @@ public void testRetryOperationOnAdminMethodQuotaPerMinutePerProjectExceeded() {
assertEquals(DB_ID, database.getId().getDatabase());
assertEquals(2, mockDatabaseAdmin.countRequestsOfType(GetDatabaseRequest.class));
}

@Test
public void testRetriesDisabledForOperationOnAdminMethodQuotaPerMinutePerProjectExceeded() {
ErrorInfo info =
ErrorInfo.newBuilder()
.putMetadata("quota_limit", "AdminMethodQuotaPerMinutePerProject")
.build();
Metadata.Key<ErrorInfo> key =
Metadata.Key.of(
info.getDescriptorForType().getFullName() + Metadata.BINARY_HEADER_SUFFIX,
ProtoLiteUtils.metadataMarshaller(info));
Metadata trailers = new Metadata();
trailers.put(key, info);
mockDatabaseAdmin.addException(
Status.RESOURCE_EXHAUSTED.withDescription("foo").asRuntimeException(trailers));
mockDatabaseAdmin.clearRequests();

Spanner spannerWithoutRetries =
spanner.getOptions().toBuilder().disableAdministrativeRequestRetries().build().getService();
AdminRequestsPerMinuteExceededException exception =
assertThrows(
AdminRequestsPerMinuteExceededException.class,
() -> spannerWithoutRetries.getDatabaseAdminClient().getDatabase(INSTANCE_ID, DB_ID));
assertEquals(ErrorCode.RESOURCE_EXHAUSTED, exception.getErrorCode());
// There should be only one request on the server, as the request was not retried.
assertEquals(1, mockDatabaseAdmin.countRequestsOfType(GetDatabaseRequest.class));
}
}