Skip to content

Commit 5fda169

Browse files
committed
docs: documents resume on update database ddl
Instead of throwing an ALREADY_EXISTS error on the update database ddl operation, we resume the original operation. This is necessary, because the update database ddl is retryable. Because of this, we don't want to confuse the caller by bubbling up an ALREADY_EXISTS error on a retry, even though they used a non-existing operation id.
1 parent 90ad9d6 commit 5fda169

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

google-cloud-spanner/src/main/java/com/google/cloud/spanner/DatabaseAdminClient.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ public OperationFuture<Database, RestoreDatabaseMetadata> restoreDatabase(
172172
* problem like a `NULL` value in a column to which `NOT NULL` would be added). If a statement
173173
* fails, all subsequent statements in the batch are automatically cancelled.
174174
*
175+
* <p>If an operation already exists with the given operation id, the operation will be resumed
176+
* and the returned future will complete when the original operation finishes. See more
177+
* information in {@link com.google.cloud.spanner.spi.v1.GapicSpannerRpc#updateDatabaseDdl(String,
178+
* Iterable, String)}
179+
*
175180
* <p>Example to update the database DDL.
176181
*
177182
* <pre>{@code

google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,17 @@ public Timestamp apply(Operation input) {
10371037
NanoClock.getDefaultClock());
10381038
}
10391039

1040+
/**
1041+
* If the update database ddl operation returns an ALREADY_EXISTS error, meaning the operation id
1042+
* used is already in flight, this method will simply resume the original operation. The returned
1043+
* future will be completed when the original operation finishes.
1044+
*
1045+
* <p>This mechanism is necessary, because the update database ddl can be retried. If a retryable
1046+
* failure occurs, the backend has already started processing the update database ddl operation
1047+
* with the given id and the library issues a retry, an ALREADY_EXISTS error will be returned. If
1048+
* we were to bubble this error up, it would be confusing for the caller, who used originally
1049+
* called the method with a new operation id.
1050+
*/
10401051
@Override
10411052
public OperationFuture<Empty, UpdateDatabaseDdlMetadata> updateDatabaseDdl(
10421053
final String databaseName,

0 commit comments

Comments
 (0)