From e6884d930668e3f53889c022278588499ddfc439 Mon Sep 17 00:00:00 2001 From: Lawrence Qiu Date: Wed, 4 Dec 2024 04:51:19 -0500 Subject: [PATCH 01/14] chore: Use Protobuf Message instead of GeneratedMessageV3 (#3435) --- .../spanner/AsyncTransactionManagerTest.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/AsyncTransactionManagerTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/AsyncTransactionManagerTest.java index 9b05a18d714..2449b8fba7c 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/AsyncTransactionManagerTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/AsyncTransactionManagerTest.java @@ -46,7 +46,7 @@ import com.google.common.collect.Range; import com.google.common.util.concurrent.MoreExecutors; import com.google.protobuf.AbstractMessage; -import com.google.protobuf.GeneratedMessageV3; +import com.google.protobuf.Message; import com.google.spanner.v1.BatchCreateSessionsRequest; import com.google.spanner.v1.BeginTransactionRequest; import com.google.spanner.v1.CommitRequest; @@ -346,7 +346,7 @@ public void asyncTransactionManagerFireAndForgetInvalidUpdate() throws Exception } } } - ImmutableList> expectedRequests = + ImmutableList> expectedRequests = ImmutableList.of( BatchCreateSessionsRequest.class, // The first update that fails. This will cause a transaction retry. @@ -671,7 +671,7 @@ public void asyncTransactionManagerFireAndForgetInvalidBatchUpdate() throws Exce } } } - ImmutableList> expectedRequests = + ImmutableList> expectedRequests = ImmutableList.of( BatchCreateSessionsRequest.class, ExecuteBatchDmlRequest.class, @@ -714,7 +714,7 @@ public void asyncTransactionManagerBatchUpdateAborted() throws Exception { assertThat(attempt.get()).isEqualTo(2); // There should only be 1 CommitRequest, as the first attempt should abort already after the // ExecuteBatchDmlRequest. - ImmutableList> expectedRequests = + ImmutableList> expectedRequests = ImmutableList.of( BatchCreateSessionsRequest.class, ExecuteBatchDmlRequest.class, @@ -756,7 +756,7 @@ public void asyncTransactionManagerBatchUpdateAbortedBeforeFirstStatement() thro assertThat(attempt.get()).isEqualTo(2); // There should only be 1 CommitRequest, as the first attempt should abort already after the // ExecuteBatchDmlRequest. - ImmutableList> expectedRequests = + ImmutableList> expectedRequests = ImmutableList.of( BatchCreateSessionsRequest.class, ExecuteBatchDmlRequest.class, @@ -816,7 +816,7 @@ public void asyncTransactionManagerWithBatchUpdateCommitAborted() throws Excepti } finally { mockSpanner.putStatementResult(StatementResult.update(UPDATE_STATEMENT, UPDATE_COUNT)); } - ImmutableList> expectedRequests = + ImmutableList> expectedRequests = ImmutableList.of( BatchCreateSessionsRequest.class, ExecuteBatchDmlRequest.class, @@ -914,7 +914,7 @@ public void asyncTransactionManagerWithBatchUpdateCommitFails() { assertThat(e.getErrorCode()).isEqualTo(ErrorCode.INVALID_ARGUMENT); assertThat(e.getMessage()).contains("mutation limit exceeded"); } - ImmutableList> expectedRequests = + ImmutableList> expectedRequests = ImmutableList.of( BatchCreateSessionsRequest.class, ExecuteBatchDmlRequest.class, CommitRequest.class); if (isMultiplexedSessionsEnabled()) { @@ -945,7 +945,7 @@ public void asyncTransactionManagerWaitsUntilAsyncBatchUpdateHasFinished() throw } } } - ImmutableList> expectedRequests = + ImmutableList> expectedRequests = ImmutableList.of( BatchCreateSessionsRequest.class, ExecuteBatchDmlRequest.class, CommitRequest.class); if (isMultiplexedSessionsEnabled()) { From 316f97146a1fb9f120b642421ec1196be9abddf0 Mon Sep 17 00:00:00 2001 From: rahul2393 Date: Wed, 4 Dec 2024 15:38:38 +0530 Subject: [PATCH 02/14] docs: add Multi Region Encryption samples (#3524) * docs: add Multi Region Encryption samples * add create backup sample * chore: generate libraries at Wed Dec 4 08:33:54 UTC 2024 * add sample for CopyBackup with multi region encryption keys * add restore backup sample * fix sample * chore: generate libraries at Wed Dec 4 09:25:28 UTC 2024 --------- Co-authored-by: cloud-java-bot --- README.md | 4 + ...opyBackupWithMultiRegionEncryptionKey.java | 125 ++++++++++++++++++ ...ateBackupWithMultiRegionEncryptionKey.java | 123 +++++++++++++++++ ...eDatabaseWithMultiRegionEncryptionKey.java | 106 +++++++++++++++ ...oreBackupWithMultiRegionEncryptionKey.java | 98 ++++++++++++++ 5 files changed, 456 insertions(+) create mode 100644 samples/snippets/src/main/java/com/example/spanner/CopyBackupWithMultiRegionEncryptionKey.java create mode 100644 samples/snippets/src/main/java/com/example/spanner/CreateBackupWithMultiRegionEncryptionKey.java create mode 100644 samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithMultiRegionEncryptionKey.java create mode 100644 samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithMultiRegionEncryptionKey.java diff --git a/README.md b/README.md index 993c814ccbc..ad61822f8b0 100644 --- a/README.md +++ b/README.md @@ -505,9 +505,12 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-spanner/tree/ | Batch Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/BatchSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/BatchSample.java) | | Batch Write At Least Once Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/BatchWriteAtLeastOnceSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/BatchWriteAtLeastOnceSample.java) | | Copy Backup Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/CopyBackupSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/CopyBackupSample.java) | +| Copy Backup With Multi Region Encryption Key | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/CopyBackupWithMultiRegionEncryptionKey.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/CopyBackupWithMultiRegionEncryptionKey.java) | | Create Backup With Encryption Key | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/CreateBackupWithEncryptionKey.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/CreateBackupWithEncryptionKey.java) | +| Create Backup With Multi Region Encryption Key | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/CreateBackupWithMultiRegionEncryptionKey.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/CreateBackupWithMultiRegionEncryptionKey.java) | | Create Database With Default Leader Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithDefaultLeaderSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithDefaultLeaderSample.java) | | Create Database With Encryption Key | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithEncryptionKey.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithEncryptionKey.java) | +| Create Database With Multi Region Encryption Key | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithMultiRegionEncryptionKey.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithMultiRegionEncryptionKey.java) | | Create Database With Version Retention Period Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithVersionRetentionPeriodSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithVersionRetentionPeriodSample.java) | | Create Full Backup Schedule Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/CreateFullBackupScheduleSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/CreateFullBackupScheduleSample.java) | | Create Incremental Backup Schedule Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/CreateIncrementalBackupScheduleSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/CreateIncrementalBackupScheduleSample.java) | @@ -560,6 +563,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/java-spanner/tree/ | Quickstart Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/QuickstartSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/QuickstartSample.java) | | Read Data With Database Role | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/ReadDataWithDatabaseRole.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/ReadDataWithDatabaseRole.java) | | Restore Backup With Encryption Key | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithEncryptionKey.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithEncryptionKey.java) | +| Restore Backup With Multi Region Encryption Key | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithMultiRegionEncryptionKey.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithMultiRegionEncryptionKey.java) | | Set Max Commit Delay Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/SetMaxCommitDelaySample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/SetMaxCommitDelaySample.java) | | Singer Proto | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/SingerProto.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/SingerProto.java) | | Spanner Graph Sample | [source code](https://github.com/googleapis/java-spanner/blob/main/samples/snippets/src/main/java/com/example/spanner/SpannerGraphSample.java) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/java-spanner&page=editor&open_in_editor=samples/snippets/src/main/java/com/example/spanner/SpannerGraphSample.java) | diff --git a/samples/snippets/src/main/java/com/example/spanner/CopyBackupWithMultiRegionEncryptionKey.java b/samples/snippets/src/main/java/com/example/spanner/CopyBackupWithMultiRegionEncryptionKey.java new file mode 100644 index 00000000000..4fe60a775e5 --- /dev/null +++ b/samples/snippets/src/main/java/com/example/spanner/CopyBackupWithMultiRegionEncryptionKey.java @@ -0,0 +1,125 @@ +/* + * Copyright 2024 Google Inc. + * + * 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.example.spanner; + +// [START spanner_copy_backup_with_MR_CMEK] + +import com.google.cloud.Timestamp; +import com.google.cloud.spanner.Spanner; +import com.google.cloud.spanner.SpannerException; +import com.google.cloud.spanner.SpannerExceptionFactory; +import com.google.cloud.spanner.SpannerOptions; +import com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient; +import com.google.common.collect.ImmutableList; +import com.google.spanner.admin.database.v1.Backup; +import com.google.spanner.admin.database.v1.BackupName; +import com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig; +import com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig.EncryptionType; +import com.google.spanner.admin.database.v1.CopyBackupRequest; +import com.google.spanner.admin.database.v1.InstanceName; +import java.time.Instant; +import java.time.OffsetDateTime; +import java.time.ZoneId; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; + +public class CopyBackupWithMultiRegionEncryptionKey { + + static void copyBackupWithMultiRegionEncryptionKey() { + // TODO(developer): Replace these variables before running the sample. + String projectId = "my-project"; + String instanceId = "my-instance"; + String sourceBackupId = "my-backup"; + String destinationBackupId = "my-destination-backup"; + String[] kmsKeyNames = + new String[] { + "projects/" + projectId + "/locations//keyRings//cryptoKeys/", + "projects/" + projectId + "/locations//keyRings//cryptoKeys/", + "projects/" + projectId + "/locations//keyRings//cryptoKeys/" + }; + + try (Spanner spanner = + SpannerOptions.newBuilder().setProjectId(projectId).build().getService(); + DatabaseAdminClient databaseAdminClient = spanner.createDatabaseAdminClient()) { + copyBackupWithMultiRegionEncryptionKey( + databaseAdminClient, + projectId, + instanceId, + sourceBackupId, + destinationBackupId, + kmsKeyNames); + } + } + + static void copyBackupWithMultiRegionEncryptionKey( + DatabaseAdminClient databaseAdminClient, + String projectId, + String instanceId, + String sourceBackupId, + String destinationBackupId, + String[] kmsKeyNames) { + + Timestamp expireTime = + Timestamp.ofTimeMicroseconds( + TimeUnit.MICROSECONDS.convert( + System.currentTimeMillis() + TimeUnit.DAYS.toMillis(14), TimeUnit.MILLISECONDS)); + + // Initiate the request which returns an OperationFuture. + System.out.println("Copying backup [" + destinationBackupId + "]..."); + CopyBackupRequest request = + CopyBackupRequest.newBuilder() + .setParent(InstanceName.of(projectId, instanceId).toString()) + .setBackupId(destinationBackupId) + .setSourceBackup(BackupName.of(projectId, instanceId, sourceBackupId).toString()) + .setExpireTime(expireTime.toProto()) + .setEncryptionConfig( + CopyBackupEncryptionConfig.newBuilder() + .setEncryptionType(EncryptionType.CUSTOMER_MANAGED_ENCRYPTION) + .addAllKmsKeyNames(ImmutableList.copyOf(kmsKeyNames)) + .build()) + .build(); + Backup destinationBackup; + try { + // Creates a copy of an existing backup. + // Wait for the backup operation to complete. + destinationBackup = databaseAdminClient.copyBackupAsync(request).get(); + System.out.println("Copied backup [" + destinationBackup.getName() + "]"); + } catch (ExecutionException e) { + throw (SpannerException) e.getCause(); + } catch (InterruptedException e) { + throw SpannerExceptionFactory.propagateInterrupt(e); + } + // Load the metadata of the new backup from the server. + destinationBackup = databaseAdminClient.getBackup(destinationBackup.getName()); + System.out.println( + String.format( + "Backup %s of size %d bytes was copied at %s for version of database at %s", + destinationBackup.getName(), + destinationBackup.getSizeBytes(), + OffsetDateTime.ofInstant( + Instant.ofEpochSecond( + destinationBackup.getCreateTime().getSeconds(), + destinationBackup.getCreateTime().getNanos()), + ZoneId.systemDefault()), + OffsetDateTime.ofInstant( + Instant.ofEpochSecond( + destinationBackup.getVersionTime().getSeconds(), + destinationBackup.getVersionTime().getNanos()), + ZoneId.systemDefault()))); + } +} +// [END spanner_copy_backup_with_MR_CMEK] diff --git a/samples/snippets/src/main/java/com/example/spanner/CreateBackupWithMultiRegionEncryptionKey.java b/samples/snippets/src/main/java/com/example/spanner/CreateBackupWithMultiRegionEncryptionKey.java new file mode 100644 index 00000000000..eb8f669deda --- /dev/null +++ b/samples/snippets/src/main/java/com/example/spanner/CreateBackupWithMultiRegionEncryptionKey.java @@ -0,0 +1,123 @@ +/* + * Copyright 2024 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.example.spanner; + +// [START spanner_create_backup_with_MR_CMEK] + +import com.google.cloud.spanner.Spanner; +import com.google.cloud.spanner.SpannerExceptionFactory; +import com.google.cloud.spanner.SpannerOptions; +import com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient; +import com.google.common.collect.ImmutableList; +import com.google.protobuf.Timestamp; +import com.google.spanner.admin.database.v1.Backup; +import com.google.spanner.admin.database.v1.BackupName; +import com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig; +import com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig.EncryptionType; +import com.google.spanner.admin.database.v1.CreateBackupRequest; +import com.google.spanner.admin.database.v1.DatabaseName; +import com.google.spanner.admin.database.v1.InstanceName; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import org.threeten.bp.LocalDateTime; +import org.threeten.bp.OffsetDateTime; + +public class CreateBackupWithMultiRegionEncryptionKey { + + static void createBackupWithMultiRegionEncryptionKey() { + // TODO(developer): Replace these variables before running the sample. + String projectId = "my-project"; + String instanceId = "my-instance"; + String databaseId = "my-database"; + String backupId = "my-backup"; + String[] kmsKeyNames = + new String[] { + "projects/" + projectId + "/locations//keyRings//cryptoKeys/", + "projects/" + projectId + "/locations//keyRings//cryptoKeys/", + "projects/" + projectId + "/locations//keyRings//cryptoKeys/" + }; + + try (Spanner spanner = + SpannerOptions.newBuilder().setProjectId(projectId).build().getService(); + DatabaseAdminClient adminClient = spanner.createDatabaseAdminClient()) { + createBackupWithMultiRegionEncryptionKey( + adminClient, projectId, instanceId, databaseId, backupId, kmsKeyNames); + } + } + + static Void createBackupWithMultiRegionEncryptionKey( + DatabaseAdminClient adminClient, + String projectId, + String instanceId, + String databaseId, + String backupId, + String[] kmsKeyNames) { + // Set expire time to 14 days from now. + final Timestamp expireTime = + Timestamp.newBuilder() + .setSeconds( + TimeUnit.MILLISECONDS.toSeconds( + (System.currentTimeMillis() + TimeUnit.DAYS.toMillis(14)))) + .build(); + final BackupName backupName = BackupName.of(projectId, instanceId, backupId); + Backup backup = + Backup.newBuilder() + .setName(backupName.toString()) + .setDatabase(DatabaseName.of(projectId, instanceId, databaseId).toString()) + .setExpireTime(expireTime) + .build(); + + final CreateBackupRequest request = + CreateBackupRequest.newBuilder() + .setParent(InstanceName.of(projectId, instanceId).toString()) + .setBackupId(backupId) + .setBackup(backup) + .setEncryptionConfig( + CreateBackupEncryptionConfig.newBuilder() + .setEncryptionType(EncryptionType.CUSTOMER_MANAGED_ENCRYPTION) + .addAllKmsKeyNames(ImmutableList.copyOf(kmsKeyNames)) + .build()) + .build(); + try { + System.out.println("Waiting for operation to complete..."); + backup = adminClient.createBackupAsync(request).get(1200, TimeUnit.SECONDS); + } catch (ExecutionException e) { + // If the operation failed during execution, expose the cause. + throw SpannerExceptionFactory.asSpannerException(e.getCause()); + } catch (InterruptedException e) { + // Throw when a thread is waiting, sleeping, or otherwise occupied, + // and the thread is interrupted, either before or during the activity. + throw SpannerExceptionFactory.propagateInterrupt(e); + } catch (TimeoutException e) { + // If the operation timed out propagates the timeout + throw SpannerExceptionFactory.propagateTimeout(e); + } + System.out.printf( + "Backup %s of size %d bytes was created at %s using encryption keys %s%n", + backup.getName(), + backup.getSizeBytes(), + LocalDateTime.ofEpochSecond( + backup.getCreateTime().getSeconds(), + backup.getCreateTime().getNanos(), + OffsetDateTime.now().getOffset()), + ImmutableList.copyOf(kmsKeyNames)); + + return null; + } +} +// [END spanner_create_backup_with_MR_CMEK] diff --git a/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithMultiRegionEncryptionKey.java b/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithMultiRegionEncryptionKey.java new file mode 100644 index 00000000000..962b5b1d5d0 --- /dev/null +++ b/samples/snippets/src/main/java/com/example/spanner/CreateDatabaseWithMultiRegionEncryptionKey.java @@ -0,0 +1,106 @@ +/* + * Copyright 2024 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.example.spanner; + +// [START spanner_create_database_with_MR_CMEK] + +import com.google.cloud.spanner.Spanner; +import com.google.cloud.spanner.SpannerExceptionFactory; +import com.google.cloud.spanner.SpannerOptions; +import com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient; +import com.google.common.collect.ImmutableList; +import com.google.spanner.admin.database.v1.CreateDatabaseRequest; +import com.google.spanner.admin.database.v1.Database; +import com.google.spanner.admin.database.v1.EncryptionConfig; +import com.google.spanner.admin.database.v1.InstanceName; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +public class CreateDatabaseWithMultiRegionEncryptionKey { + + static void createDatabaseWithEncryptionKey() { + // TODO(developer): Replace these variables before running the sample. + String projectId = "my-project"; + String instanceId = "my-instance"; + String databaseId = "my-database"; + String[] kmsKeyNames = + new String[] { + "projects/" + projectId + "/locations//keyRings//cryptoKeys/", + "projects/" + projectId + "/locations//keyRings//cryptoKeys/", + "projects/" + projectId + "/locations//keyRings//cryptoKeys/" + }; + try (Spanner spanner = + SpannerOptions.newBuilder().setProjectId(projectId).build().getService(); + DatabaseAdminClient adminClient = spanner.createDatabaseAdminClient()) { + createDatabaseWithMultiRegionEncryptionKey( + adminClient, projectId, instanceId, databaseId, kmsKeyNames); + } + } + + static void createDatabaseWithMultiRegionEncryptionKey( + DatabaseAdminClient adminClient, + String projectId, + String instanceId, + String databaseId, + String[] kmsKeyNames) { + InstanceName instanceName = InstanceName.of(projectId, instanceId); + CreateDatabaseRequest request = + CreateDatabaseRequest.newBuilder() + .setParent(instanceName.toString()) + .setCreateStatement("CREATE DATABASE `" + databaseId + "`") + .setEncryptionConfig( + EncryptionConfig.newBuilder() + .addAllKmsKeyNames(ImmutableList.copyOf(kmsKeyNames)) + .build()) + .addAllExtraStatements( + ImmutableList.of( + "CREATE TABLE Singers (" + + " SingerId INT64 NOT NULL," + + " FirstName STRING(1024)," + + " LastName STRING(1024)," + + " SingerInfo BYTES(MAX)" + + ") PRIMARY KEY (SingerId)", + "CREATE TABLE Albums (" + + " SingerId INT64 NOT NULL," + + " AlbumId INT64 NOT NULL," + + " AlbumTitle STRING(MAX)" + + ") PRIMARY KEY (SingerId, AlbumId)," + + " INTERLEAVE IN PARENT Singers ON DELETE CASCADE")) + .build(); + try { + System.out.println("Waiting for operation to complete..."); + Database createdDatabase = + adminClient.createDatabaseAsync(request).get(120, TimeUnit.SECONDS); + + System.out.printf( + "Database %s created with encryption keys %s%n", + createdDatabase.getName(), createdDatabase.getEncryptionConfig().getKmsKeyNamesList()); + } catch (ExecutionException e) { + // If the operation failed during execution, expose the cause. + throw SpannerExceptionFactory.asSpannerException(e.getCause()); + } catch (InterruptedException e) { + // Throw when a thread is waiting, sleeping, or otherwise occupied, + // and the thread is interrupted, either before or during the activity. + throw SpannerExceptionFactory.propagateInterrupt(e); + } catch (TimeoutException e) { + // If the operation timed out propagates the timeout + throw SpannerExceptionFactory.propagateTimeout(e); + } + } +} +// [END spanner_create_database_with_MR_CMEK] diff --git a/samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithMultiRegionEncryptionKey.java b/samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithMultiRegionEncryptionKey.java new file mode 100644 index 00000000000..a13ff4b8cd0 --- /dev/null +++ b/samples/snippets/src/main/java/com/example/spanner/RestoreBackupWithMultiRegionEncryptionKey.java @@ -0,0 +1,98 @@ +/* + * Copyright 2024 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.example.spanner; + +// [START spanner_restore_backup_with_MR_CMEK] + +import static com.google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig.EncryptionType.CUSTOMER_MANAGED_ENCRYPTION; + +import com.google.cloud.spanner.Spanner; +import com.google.cloud.spanner.SpannerExceptionFactory; +import com.google.cloud.spanner.SpannerOptions; +import com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient; +import com.google.common.collect.ImmutableList; +import com.google.spanner.admin.database.v1.BackupName; +import com.google.spanner.admin.database.v1.Database; +import com.google.spanner.admin.database.v1.InstanceName; +import com.google.spanner.admin.database.v1.RestoreDatabaseEncryptionConfig; +import com.google.spanner.admin.database.v1.RestoreDatabaseRequest; +import java.util.concurrent.ExecutionException; + +public class RestoreBackupWithMultiRegionEncryptionKey { + + static void restoreBackupWithMultiRegionEncryptionKey() { + // TODO(developer): Replace these variables before running the sample. + String projectId = "my-project"; + String instanceId = "my-instance"; + String databaseId = "my-database"; + String backupId = "my-backup"; + String[] kmsKeyNames = + new String[] { + "projects/" + projectId + "/locations//keyRings//cryptoKeys/", + "projects/" + projectId + "/locations//keyRings//cryptoKeys/", + "projects/" + projectId + "/locations//keyRings//cryptoKeys/" + }; + + try (Spanner spanner = + SpannerOptions.newBuilder().setProjectId(projectId).build().getService(); + DatabaseAdminClient adminClient = spanner.createDatabaseAdminClient()) { + restoreBackupWithMultiRegionEncryptionKey( + adminClient, projectId, instanceId, backupId, databaseId, kmsKeyNames); + } + } + + static Void restoreBackupWithMultiRegionEncryptionKey( + DatabaseAdminClient adminClient, + String projectId, + String instanceId, + String backupId, + String restoreId, + String[] kmsKeyNames) { + RestoreDatabaseRequest request = + RestoreDatabaseRequest.newBuilder() + .setParent(InstanceName.of(projectId, instanceId).toString()) + .setDatabaseId(restoreId) + .setBackup(BackupName.of(projectId, instanceId, backupId).toString()) + .setEncryptionConfig( + RestoreDatabaseEncryptionConfig.newBuilder() + .setEncryptionType(CUSTOMER_MANAGED_ENCRYPTION) + .addAllKmsKeyNames(ImmutableList.copyOf(kmsKeyNames))) + .build(); + Database database; + try { + System.out.println("Waiting for operation to complete..."); + database = adminClient.restoreDatabaseAsync(request).get(); + ; + } catch (ExecutionException e) { + // If the operation failed during execution, expose the cause. + throw SpannerExceptionFactory.asSpannerException(e.getCause()); + } catch (InterruptedException e) { + // Throw when a thread is waiting, sleeping, or otherwise occupied, + // and the thread is interrupted, either before or during the activity. + throw SpannerExceptionFactory.propagateInterrupt(e); + } + + System.out.printf( + "Database %s restored to %s from backup %s using encryption keys %s%n", + database.getRestoreInfo().getBackupInfo().getSourceDatabase(), + database.getName(), + database.getRestoreInfo().getBackupInfo().getBackup(), + database.getEncryptionConfig().getKmsKeyNamesList()); + return null; + } +} +// [END spanner_restore_backup_with_MR_CMEK] From 01eafce8848dd886f027a74843ca6712a6942ff1 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Wed, 4 Dec 2024 16:22:46 +0530 Subject: [PATCH 03/14] chore(main): release 6.82.0 (#3525) * chore(main): release 6.82.0 * chore: generate libraries at Wed Dec 4 10:11:11 UTC 2024 --------- Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: cloud-java-bot --- CHANGELOG.md | 25 +++++++++++++++++++ README.md | 6 ++--- benchmarks/pom.xml | 2 +- google-cloud-spanner-bom/pom.xml | 18 ++++++------- google-cloud-spanner-executor/pom.xml | 4 +-- google-cloud-spanner/pom.xml | 4 +-- .../pom.xml | 4 +-- .../pom.xml | 4 +-- grpc-google-cloud-spanner-executor-v1/pom.xml | 4 +-- grpc-google-cloud-spanner-v1/pom.xml | 4 +-- pom.xml | 20 +++++++-------- .../pom.xml | 4 +-- .../pom.xml | 4 +-- .../pom.xml | 4 +-- proto-google-cloud-spanner-v1/pom.xml | 4 +-- samples/snapshot/pom.xml | 2 +- versions.txt | 20 +++++++-------- 17 files changed, 79 insertions(+), 54 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 395574d2ab1..1436e341430 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,30 @@ # Changelog +## [6.82.0](https://github.com/googleapis/java-spanner/compare/v6.81.2...v6.82.0) (2024-12-04) + + +### Features + +* Add option for retrying DML as PDML ([#3480](https://github.com/googleapis/java-spanner/issues/3480)) ([b545557](https://github.com/googleapis/java-spanner/commit/b545557b1a27868aeb5115b3947d42db015cc00e)) +* Add the last statement option to ExecuteSqlRequest and ExecuteBatchDmlRequest ([76ab801](https://github.com/googleapis/java-spanner/commit/76ab8011b0aa03e5bb98e375595358732cde31b7)) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.50.0 ([76ab801](https://github.com/googleapis/java-spanner/commit/76ab8011b0aa03e5bb98e375595358732cde31b7)) +* Shutdown built in metrics meter provider ([#3518](https://github.com/googleapis/java-spanner/issues/3518)) ([c935e2e](https://github.com/googleapis/java-spanner/commit/c935e2eff780100273bc35c11458485c9bb05230)) +* **spanner:** GetEdition() is returning null for Instance ([#3496](https://github.com/googleapis/java-spanner/issues/3496)) ([77cb585](https://github.com/googleapis/java-spanner/commit/77cb585d57fd30f953b0ffb80be124e3cb1c6f39)) + + +### Dependencies + +* Update dependency commons-io:commons-io to v2.18.0 ([#3492](https://github.com/googleapis/java-spanner/issues/3492)) ([5c8b3ad](https://github.com/googleapis/java-spanner/commit/5c8b3ade163b4cdb81a53f5dcf777ebba48ef265)) + + +### Documentation + +* Add Multi Region Encryption samples ([#3524](https://github.com/googleapis/java-spanner/issues/3524)) ([316f971](https://github.com/googleapis/java-spanner/commit/316f97146a1fb9f120b642421ec1196be9abddf0)) + ## [6.81.2](https://github.com/googleapis/java-spanner/compare/v6.81.1...v6.81.2) (2024-11-20) diff --git a/README.md b/README.md index ad61822f8b0..29f1bb0322d 100644 --- a/README.md +++ b/README.md @@ -56,13 +56,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.81.2' +implementation 'com.google.cloud:google-cloud-spanner:6.82.0' ``` If you are using SBT, add this to your dependencies: ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-spanner" % "6.81.2" +libraryDependencies += "com.google.cloud" % "google-cloud-spanner" % "6.82.0" ``` ## Authentication @@ -725,7 +725,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.81.2 +[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-spanner/6.82.0 [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 diff --git a/benchmarks/pom.xml b/benchmarks/pom.xml index 1954a1a1348..22c13635ce8 100644 --- a/benchmarks/pom.xml +++ b/benchmarks/pom.xml @@ -24,7 +24,7 @@ com.google.cloud google-cloud-spanner-parent - 6.81.3-SNAPSHOT + 6.82.0 diff --git a/google-cloud-spanner-bom/pom.xml b/google-cloud-spanner-bom/pom.xml index 206d9b3dd1a..1db01f10946 100644 --- a/google-cloud-spanner-bom/pom.xml +++ b/google-cloud-spanner-bom/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-spanner-bom - 6.81.3-SNAPSHOT + 6.82.0 pom com.google.cloud @@ -53,43 +53,43 @@ com.google.cloud google-cloud-spanner - 6.81.3-SNAPSHOT + 6.82.0 com.google.cloud google-cloud-spanner test-jar - 6.81.3-SNAPSHOT + 6.82.0 com.google.api.grpc grpc-google-cloud-spanner-v1 - 6.81.3-SNAPSHOT + 6.82.0 com.google.api.grpc grpc-google-cloud-spanner-admin-instance-v1 - 6.81.3-SNAPSHOT + 6.82.0 com.google.api.grpc grpc-google-cloud-spanner-admin-database-v1 - 6.81.3-SNAPSHOT + 6.82.0 com.google.api.grpc proto-google-cloud-spanner-admin-instance-v1 - 6.81.3-SNAPSHOT + 6.82.0 com.google.api.grpc proto-google-cloud-spanner-v1 - 6.81.3-SNAPSHOT + 6.82.0 com.google.api.grpc proto-google-cloud-spanner-admin-database-v1 - 6.81.3-SNAPSHOT + 6.82.0 diff --git a/google-cloud-spanner-executor/pom.xml b/google-cloud-spanner-executor/pom.xml index e8f01722d93..c108b69b1a3 100644 --- a/google-cloud-spanner-executor/pom.xml +++ b/google-cloud-spanner-executor/pom.xml @@ -5,14 +5,14 @@ 4.0.0 com.google.cloud google-cloud-spanner-executor - 6.81.3-SNAPSHOT + 6.82.0 jar Google Cloud Spanner Executor com.google.cloud google-cloud-spanner-parent - 6.81.3-SNAPSHOT + 6.82.0 diff --git a/google-cloud-spanner/pom.xml b/google-cloud-spanner/pom.xml index c4a9cc09539..b7589c10203 100644 --- a/google-cloud-spanner/pom.xml +++ b/google-cloud-spanner/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-spanner - 6.81.3-SNAPSHOT + 6.82.0 jar Google Cloud Spanner https://github.com/googleapis/java-spanner @@ -11,7 +11,7 @@ com.google.cloud google-cloud-spanner-parent - 6.81.3-SNAPSHOT + 6.82.0 google-cloud-spanner diff --git a/grpc-google-cloud-spanner-admin-database-v1/pom.xml b/grpc-google-cloud-spanner-admin-database-v1/pom.xml index 91aacbe2719..000a88b6261 100644 --- a/grpc-google-cloud-spanner-admin-database-v1/pom.xml +++ b/grpc-google-cloud-spanner-admin-database-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-spanner-admin-database-v1 - 6.81.3-SNAPSHOT + 6.82.0 grpc-google-cloud-spanner-admin-database-v1 GRPC library for grpc-google-cloud-spanner-admin-database-v1 com.google.cloud google-cloud-spanner-parent - 6.81.3-SNAPSHOT + 6.82.0 diff --git a/grpc-google-cloud-spanner-admin-instance-v1/pom.xml b/grpc-google-cloud-spanner-admin-instance-v1/pom.xml index 8423332b6c3..b794aca19dd 100644 --- a/grpc-google-cloud-spanner-admin-instance-v1/pom.xml +++ b/grpc-google-cloud-spanner-admin-instance-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-spanner-admin-instance-v1 - 6.81.3-SNAPSHOT + 6.82.0 grpc-google-cloud-spanner-admin-instance-v1 GRPC library for grpc-google-cloud-spanner-admin-instance-v1 com.google.cloud google-cloud-spanner-parent - 6.81.3-SNAPSHOT + 6.82.0 diff --git a/grpc-google-cloud-spanner-executor-v1/pom.xml b/grpc-google-cloud-spanner-executor-v1/pom.xml index c4fc06b2704..b63e9bd6038 100644 --- a/grpc-google-cloud-spanner-executor-v1/pom.xml +++ b/grpc-google-cloud-spanner-executor-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-spanner-executor-v1 - 6.81.3-SNAPSHOT + 6.82.0 grpc-google-cloud-spanner-executor-v1 GRPC library for google-cloud-spanner com.google.cloud google-cloud-spanner-parent - 6.81.3-SNAPSHOT + 6.82.0 diff --git a/grpc-google-cloud-spanner-v1/pom.xml b/grpc-google-cloud-spanner-v1/pom.xml index 5454023dd36..dc1c2c1c936 100644 --- a/grpc-google-cloud-spanner-v1/pom.xml +++ b/grpc-google-cloud-spanner-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-spanner-v1 - 6.81.3-SNAPSHOT + 6.82.0 grpc-google-cloud-spanner-v1 GRPC library for grpc-google-cloud-spanner-v1 com.google.cloud google-cloud-spanner-parent - 6.81.3-SNAPSHOT + 6.82.0 diff --git a/pom.xml b/pom.xml index 033368b3136..72a2a6797e3 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-spanner-parent pom - 6.81.3-SNAPSHOT + 6.82.0 Google Cloud Spanner Parent https://github.com/googleapis/java-spanner @@ -61,47 +61,47 @@ com.google.api.grpc proto-google-cloud-spanner-admin-instance-v1 - 6.81.3-SNAPSHOT + 6.82.0 com.google.api.grpc proto-google-cloud-spanner-executor-v1 - 6.81.3-SNAPSHOT + 6.82.0 com.google.api.grpc grpc-google-cloud-spanner-executor-v1 - 6.81.3-SNAPSHOT + 6.82.0 com.google.api.grpc proto-google-cloud-spanner-v1 - 6.81.3-SNAPSHOT + 6.82.0 com.google.api.grpc proto-google-cloud-spanner-admin-database-v1 - 6.81.3-SNAPSHOT + 6.82.0 com.google.api.grpc grpc-google-cloud-spanner-v1 - 6.81.3-SNAPSHOT + 6.82.0 com.google.api.grpc grpc-google-cloud-spanner-admin-instance-v1 - 6.81.3-SNAPSHOT + 6.82.0 com.google.api.grpc grpc-google-cloud-spanner-admin-database-v1 - 6.81.3-SNAPSHOT + 6.82.0 com.google.cloud google-cloud-spanner - 6.81.3-SNAPSHOT + 6.82.0 diff --git a/proto-google-cloud-spanner-admin-database-v1/pom.xml b/proto-google-cloud-spanner-admin-database-v1/pom.xml index e8d3a78f661..4d29a245a80 100644 --- a/proto-google-cloud-spanner-admin-database-v1/pom.xml +++ b/proto-google-cloud-spanner-admin-database-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-spanner-admin-database-v1 - 6.81.3-SNAPSHOT + 6.82.0 proto-google-cloud-spanner-admin-database-v1 PROTO library for proto-google-cloud-spanner-admin-database-v1 com.google.cloud google-cloud-spanner-parent - 6.81.3-SNAPSHOT + 6.82.0 diff --git a/proto-google-cloud-spanner-admin-instance-v1/pom.xml b/proto-google-cloud-spanner-admin-instance-v1/pom.xml index ac5b06ff1c8..08da9e3b853 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/pom.xml +++ b/proto-google-cloud-spanner-admin-instance-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-spanner-admin-instance-v1 - 6.81.3-SNAPSHOT + 6.82.0 proto-google-cloud-spanner-admin-instance-v1 PROTO library for proto-google-cloud-spanner-admin-instance-v1 com.google.cloud google-cloud-spanner-parent - 6.81.3-SNAPSHOT + 6.82.0 diff --git a/proto-google-cloud-spanner-executor-v1/pom.xml b/proto-google-cloud-spanner-executor-v1/pom.xml index a990c3c1c5b..23a213ca72f 100644 --- a/proto-google-cloud-spanner-executor-v1/pom.xml +++ b/proto-google-cloud-spanner-executor-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-spanner-executor-v1 - 6.81.3-SNAPSHOT + 6.82.0 proto-google-cloud-spanner-executor-v1 Proto library for google-cloud-spanner com.google.cloud google-cloud-spanner-parent - 6.81.3-SNAPSHOT + 6.82.0 diff --git a/proto-google-cloud-spanner-v1/pom.xml b/proto-google-cloud-spanner-v1/pom.xml index d81e8d8cfd6..8c3dc7a8adf 100644 --- a/proto-google-cloud-spanner-v1/pom.xml +++ b/proto-google-cloud-spanner-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-spanner-v1 - 6.81.3-SNAPSHOT + 6.82.0 proto-google-cloud-spanner-v1 PROTO library for proto-google-cloud-spanner-v1 com.google.cloud google-cloud-spanner-parent - 6.81.3-SNAPSHOT + 6.82.0 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index a16c9d19569..cca1680ac10 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -32,7 +32,7 @@ com.google.cloud google-cloud-spanner - 6.81.3-SNAPSHOT + 6.82.0 diff --git a/versions.txt b/versions.txt index 0cc11757a03..745b2174e24 100644 --- a/versions.txt +++ b/versions.txt @@ -1,13 +1,13 @@ # Format: # module:released-version:current-version -proto-google-cloud-spanner-admin-instance-v1:6.81.2:6.81.3-SNAPSHOT -proto-google-cloud-spanner-v1:6.81.2:6.81.3-SNAPSHOT -proto-google-cloud-spanner-admin-database-v1:6.81.2:6.81.3-SNAPSHOT -grpc-google-cloud-spanner-v1:6.81.2:6.81.3-SNAPSHOT -grpc-google-cloud-spanner-admin-instance-v1:6.81.2:6.81.3-SNAPSHOT -grpc-google-cloud-spanner-admin-database-v1:6.81.2:6.81.3-SNAPSHOT -google-cloud-spanner:6.81.2:6.81.3-SNAPSHOT -google-cloud-spanner-executor:6.81.2:6.81.3-SNAPSHOT -proto-google-cloud-spanner-executor-v1:6.81.2:6.81.3-SNAPSHOT -grpc-google-cloud-spanner-executor-v1:6.81.2:6.81.3-SNAPSHOT +proto-google-cloud-spanner-admin-instance-v1:6.82.0:6.82.0 +proto-google-cloud-spanner-v1:6.82.0:6.82.0 +proto-google-cloud-spanner-admin-database-v1:6.82.0:6.82.0 +grpc-google-cloud-spanner-v1:6.82.0:6.82.0 +grpc-google-cloud-spanner-admin-instance-v1:6.82.0:6.82.0 +grpc-google-cloud-spanner-admin-database-v1:6.82.0:6.82.0 +google-cloud-spanner:6.82.0:6.82.0 +google-cloud-spanner-executor:6.82.0:6.82.0 +proto-google-cloud-spanner-executor-v1:6.82.0:6.82.0 +grpc-google-cloud-spanner-executor-v1:6.82.0:6.82.0 From 4ed455a43edf7ff8d138ce4d40a52d3224383b14 Mon Sep 17 00:00:00 2001 From: surbhigarg92 Date: Thu, 5 Dec 2024 18:06:49 +0530 Subject: [PATCH 04/14] feat: Add Metrics host for built in metrics (#3519) This PR allows users to set the custom monitoring host for built in metrics. --- .../clirr-ignored-differences.xml | 7 +++++ .../BuiltInOpenTelemetryMetricsProvider.java | 6 +++-- .../SpannerCloudMonitoringExporter.java | 15 ++++------- .../google/cloud/spanner/SpannerOptions.java | 27 ++++++++++++++++++- .../SpannerCloudMonitoringExporterTest.java | 4 +-- .../cloud/spanner/SpannerOptionsTest.java | 13 +++++++++ 6 files changed, 57 insertions(+), 15 deletions(-) diff --git a/google-cloud-spanner/clirr-ignored-differences.xml b/google-cloud-spanner/clirr-ignored-differences.xml index bae308f2b50..5b84cb4ebc3 100644 --- a/google-cloud-spanner/clirr-ignored-differences.xml +++ b/google-cloud-spanner/clirr-ignored-differences.xml @@ -709,6 +709,13 @@ boolean isEnableBuiltInMetrics() + + + 7012 + com/google/cloud/spanner/SpannerOptions$SpannerEnvironment + java.lang.String getMonitoringHost() + + 7012 diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/BuiltInOpenTelemetryMetricsProvider.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/BuiltInOpenTelemetryMetricsProvider.java index 8f4ada6ae57..4aeb98987d1 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/BuiltInOpenTelemetryMetricsProvider.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/BuiltInOpenTelemetryMetricsProvider.java @@ -59,12 +59,14 @@ final class BuiltInOpenTelemetryMetricsProvider { private BuiltInOpenTelemetryMetricsProvider() {} - OpenTelemetry getOrCreateOpenTelemetry(String projectId, @Nullable Credentials credentials) { + OpenTelemetry getOrCreateOpenTelemetry( + String projectId, @Nullable Credentials credentials, @Nullable String monitoringHost) { try { if (this.openTelemetry == null) { SdkMeterProviderBuilder sdkMeterProviderBuilder = SdkMeterProvider.builder(); BuiltInOpenTelemetryMetricsView.registerBuiltinMetrics( - SpannerCloudMonitoringExporter.create(projectId, credentials), sdkMeterProviderBuilder); + SpannerCloudMonitoringExporter.create(projectId, credentials, monitoringHost), + sdkMeterProviderBuilder); SdkMeterProvider sdkMeterProvider = sdkMeterProviderBuilder.build(); this.openTelemetry = OpenTelemetrySdk.builder().setMeterProvider(sdkMeterProvider).build(); Runtime.getRuntime().addShutdownHook(new Thread(sdkMeterProvider::close)); diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerCloudMonitoringExporter.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerCloudMonitoringExporter.java index 3577c9f7b45..fc101fbcfc3 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerCloudMonitoringExporter.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerCloudMonitoringExporter.java @@ -29,7 +29,6 @@ import com.google.cloud.monitoring.v3.MetricServiceClient; import com.google.cloud.monitoring.v3.MetricServiceSettings; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.MoreObjects; import com.google.common.collect.Iterables; import com.google.common.util.concurrent.MoreExecutors; import com.google.monitoring.v3.CreateTimeSeriesRequest; @@ -63,13 +62,6 @@ class SpannerCloudMonitoringExporter implements MetricExporter { private static final Logger logger = Logger.getLogger(SpannerCloudMonitoringExporter.class.getName()); - // This system property can be used to override the monitoring endpoint - // to a different environment. It's meant for internal testing only. - private static final String MONITORING_ENDPOINT = - MoreObjects.firstNonNull( - System.getProperty("spanner.test-monitoring-endpoint"), - MetricServiceSettings.getDefaultEndpoint()); - // This the quota limit from Cloud Monitoring. More details in // https://cloud.google.com/monitoring/quotas#custom_metrics_quotas. private static final int EXPORT_BATCH_SIZE_LIMIT = 200; @@ -78,7 +70,8 @@ class SpannerCloudMonitoringExporter implements MetricExporter { private final MetricServiceClient client; private final String spannerProjectId; - static SpannerCloudMonitoringExporter create(String projectId, @Nullable Credentials credentials) + static SpannerCloudMonitoringExporter create( + String projectId, @Nullable Credentials credentials, @Nullable String monitoringHost) throws IOException { MetricServiceSettings.Builder settingsBuilder = MetricServiceSettings.newBuilder(); CredentialsProvider credentialsProvider; @@ -88,7 +81,9 @@ static SpannerCloudMonitoringExporter create(String projectId, @Nullable Credent credentialsProvider = FixedCredentialsProvider.create(credentials); } settingsBuilder.setCredentialsProvider(credentialsProvider); - settingsBuilder.setEndpoint(MONITORING_ENDPOINT); + if (monitoringHost != null) { + settingsBuilder.setEndpoint(monitoringHost); + } org.threeten.bp.Duration timeout = Duration.ofMinutes(1); // TODO: createServiceTimeSeries needs special handling if the request failed. Leaving diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java index af54515e7c6..d85b39c1253 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java @@ -164,6 +164,7 @@ public class SpannerOptions extends ServiceOptions { private final boolean enableBuiltInMetrics; private final boolean enableExtendedTracing; private final boolean enableEndToEndTracing; + private final String monitoringHost; enum TracingFramework { OPEN_CENSUS, @@ -672,6 +673,7 @@ protected SpannerOptions(Builder builder) { enableExtendedTracing = builder.enableExtendedTracing; enableBuiltInMetrics = builder.enableBuiltInMetrics; enableEndToEndTracing = builder.enableEndToEndTracing; + monitoringHost = builder.monitoringHost; } /** @@ -712,6 +714,10 @@ default boolean isEnableBuiltInMetrics() { default boolean isEnableEndToEndTracing() { return false; } + + default String getMonitoringHost() { + return null; + } } /** @@ -728,6 +734,7 @@ private static class SpannerEnvironmentImpl implements SpannerEnvironment { private static final String SPANNER_ENABLE_END_TO_END_TRACING = "SPANNER_ENABLE_END_TO_END_TRACING"; private static final String SPANNER_DISABLE_BUILTIN_METRICS = "SPANNER_DISABLE_BUILTIN_METRICS"; + private static final String SPANNER_MONITORING_HOST = "SPANNER_MONITORING_HOST"; private SpannerEnvironmentImpl() {} @@ -763,6 +770,11 @@ public boolean isEnableBuiltInMetrics() { public boolean isEnableEndToEndTracing() { return Boolean.parseBoolean(System.getenv(SPANNER_ENABLE_END_TO_END_TRACING)); } + + @Override + public String getMonitoringHost() { + return System.getenv(SPANNER_MONITORING_HOST); + } } /** Builder for {@link SpannerOptions} instances. */ @@ -828,6 +840,7 @@ public static class Builder private boolean enableExtendedTracing = SpannerOptions.environment.isEnableExtendedTracing(); private boolean enableEndToEndTracing = SpannerOptions.environment.isEnableEndToEndTracing(); private boolean enableBuiltInMetrics = SpannerOptions.environment.isEnableBuiltInMetrics(); + private String monitoringHost = SpannerOptions.environment.getMonitoringHost(); private static String createCustomClientLibToken(String token) { return token + " " + ServiceOptions.getGoogApiClientLibName(); @@ -895,6 +908,7 @@ protected Builder() { this.enableExtendedTracing = options.enableExtendedTracing; this.enableBuiltInMetrics = options.enableBuiltInMetrics; this.enableEndToEndTracing = options.enableEndToEndTracing; + this.monitoringHost = options.monitoringHost; } @Override @@ -1417,6 +1431,12 @@ public Builder setBuiltInMetricsEnabled(boolean enableBuiltInMetrics) { return this; } + /** Sets the monitoring host to be used for Built-in client side metrics */ + public Builder setMonitoringHost(String monitoringHost) { + this.monitoringHost = monitoringHost; + return this; + } + /** * Sets whether to enable extended OpenTelemetry tracing. Enabling this option will add the * following additional attributes to the traces that are generated by the client: @@ -1727,7 +1747,7 @@ private ApiTracerFactory getDefaultApiTracerFactory() { private ApiTracerFactory createMetricsApiTracerFactory() { OpenTelemetry openTelemetry = this.builtInOpenTelemetryMetricsProvider.getOrCreateOpenTelemetry( - this.getProjectId(), getCredentials()); + this.getProjectId(), getCredentials(), this.monitoringHost); return openTelemetry != null ? new MetricsTracerFactory( @@ -1754,6 +1774,11 @@ public boolean isEnableBuiltInMetrics() { return enableBuiltInMetrics; } + /** Returns the override metrics Host. */ + String getMonitoringHost() { + return monitoringHost; + } + @BetaApi public boolean isUseVirtualThreads() { return useVirtualThreads; diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerCloudMonitoringExporterTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerCloudMonitoringExporterTest.java index acb7ae9fa1e..ab30de1ade0 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerCloudMonitoringExporterTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerCloudMonitoringExporterTest.java @@ -337,7 +337,7 @@ public void testExportingSumDataInBatches() { @Test public void getAggregationTemporality() throws IOException { SpannerCloudMonitoringExporter actualExporter = - SpannerCloudMonitoringExporter.create(projectId, null); + SpannerCloudMonitoringExporter.create(projectId, null, null); assertThat(actualExporter.getAggregationTemporality(InstrumentType.COUNTER)) .isEqualTo(AggregationTemporality.CUMULATIVE); } @@ -348,7 +348,7 @@ public void testSkipExportingDataIfMissingInstanceId() throws IOException { Attributes.builder().putAll(attributes).remove(INSTANCE_ID_KEY).build(); SpannerCloudMonitoringExporter actualExporter = - SpannerCloudMonitoringExporter.create(projectId, null); + SpannerCloudMonitoringExporter.create(projectId, null, null); assertThat(actualExporter.getAggregationTemporality(InstrumentType.COUNTER)) .isEqualTo(AggregationTemporality.CUMULATIVE); ArgumentCaptor argumentCaptor = diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java index e8421cd235c..7b891fdb7a9 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java @@ -754,6 +754,19 @@ public void testEndToEndTracingEnablement() { .isEndToEndTracingEnabled()); } + @Test + public void testmonitoringHost() { + String metricsEndpoint = "test-endpoint:443"; + assertNull(SpannerOptions.newBuilder().setProjectId("p").build().getMonitoringHost()); + assertThat( + SpannerOptions.newBuilder() + .setProjectId("p") + .setMonitoringHost(metricsEndpoint) + .build() + .getMonitoringHost()) + .isEqualTo(metricsEndpoint); + } + @Test public void testSetDirectedReadOptions() { final DirectedReadOptions directedReadOptions = From 8a7d533ded21b9b94992b68c702c08bb84474e1b Mon Sep 17 00:00:00 2001 From: Diego Marquez Date: Thu, 5 Dec 2024 12:22:22 -0500 Subject: [PATCH 05/14] feat: introduce java.time variables and methods (#3495) This PR introduces `java.time` alternatives to existing `org.threeten.bp.*` methods, as well as switching internal variables (if any) to `java.time` The main constraint is to keep the changes backwards compatible, so for each existing threeten method "`method1(org.threeten.bp.Duration)`" we will add an alternative with a _Duration_ (or _Timestamp_ when applicable) suffix: "`method1Duration(java.time.Duration)`". For most cases, the implementation will be held in the `java.time` method and the old threeten method will just delegate the call to it. However, for the case of abstract classes, the implementation will be kept in the threeten method to avoid breaking changes (i.e. users that already overloaded the method in their user code). --- google-cloud-spanner-executor/pom.xml | 4 - .../executor/spanner/CloudClientExecutor.java | 14 +- .../java/com/google/cloud/spanner/Clock.java | 2 +- .../google/cloud/spanner/CompositeTracer.java | 10 +- .../cloud/spanner/GrpcStreamIterator.java | 5 +- .../com/google/cloud/spanner/LatencyTest.java | 4 +- .../MultiplexedSessionDatabaseClient.java | 2 +- .../cloud/spanner/OpenTelemetryApiTracer.java | 14 +- .../com/google/cloud/spanner/Operation.java | 8 +- .../spanner/PartitionedDmlTransaction.java | 4 +- .../com/google/cloud/spanner/SessionImpl.java | 4 +- .../com/google/cloud/spanner/SessionPool.java | 6 +- .../cloud/spanner/SessionPoolOptions.java | 54 ++++-- .../cloud/spanner/SessionReference.java | 2 +- .../SpannerCloudMonitoringExporter.java | 6 +- .../com/google/cloud/spanner/SpannerImpl.java | 2 +- .../google/cloud/spanner/SpannerOptions.java | 182 +++++++++++++++--- .../cloud/spanner/SpannerRetryHelper.java | 6 +- .../connection/AbstractBaseUnitOfWork.java | 2 +- .../spanner/connection/ConnectionImpl.java | 2 +- .../connection/LocalConnectionChecker.java | 4 +- .../spanner/connection/StatementExecutor.java | 20 +- .../cloud/spanner/spi/v1/GapicSpannerRpc.java | 19 +- .../cloud/spanner/spi/v1/SpannerRpc.java | 2 +- .../spanner/BatchCreateSessionsSlowTest.java | 11 +- .../CloseSpannerWithOpenResultSetTest.java | 6 +- .../cloud/spanner/CompositeTracerTest.java | 12 +- .../spanner/DatabaseAdminClientTest.java | 44 ++--- .../cloud/spanner/DatabaseAdminGaxTest.java | 22 +-- .../cloud/spanner/DatabaseClientImplTest.java | 52 ++--- .../cloud/spanner/DefaultBenchmark.java | 10 +- .../com/google/cloud/spanner/FakeClock.java | 2 +- .../cloud/spanner/GrpcResultSetTest.java | 4 +- .../cloud/spanner/InstanceAdminGaxTest.java | 22 +-- .../spanner/LongRunningSessionsBenchmark.java | 4 +- .../MockDatabaseAdminServiceImplTest.java | 32 +-- .../cloud/spanner/MockSpannerServiceImpl.java | 2 +- ...edSessionDatabaseClientMockServerTest.java | 2 +- .../MultiplexedSessionDatabaseClientTest.java | 2 +- .../spanner/MultiplexedSessionsBenchmark.java | 8 +- .../spanner/OpenCensusApiTracerTest.java | 12 +- .../spanner/OpenTelemetryApiTracerTest.java | 12 +- ...OpenTelemetryBuiltInMetricsTracerTest.java | 10 +- .../cloud/spanner/OpenTelemetrySpanTest.java | 4 +- .../google/cloud/spanner/OperationTest.java | 10 +- .../PartitionedDmlTransactionTest.java | 2 +- ...yOnDifferentGrpcChannelMockServerTest.java | 16 +- .../cloud/spanner/SamplesMockServerTest.java | 12 +- .../SessionPoolMaintainerBenchmark.java | 4 +- .../SessionPoolMaintainerMockServerTest.java | 4 +- .../cloud/spanner/SessionPoolOptionsTest.java | 19 +- .../google/cloud/spanner/SessionPoolTest.java | 16 +- .../cloud/spanner/SpanExceptionTest.java | 4 +- .../com/google/cloud/spanner/SpanTest.java | 24 +-- .../cloud/spanner/SpannerGaxRetryTest.java | 27 +-- .../cloud/spanner/SpannerOptionsTest.java | 156 +++++++-------- .../connection/StatementTimeoutTest.java | 8 +- .../spanner/it/ITBuiltInMetricsTest.java | 4 +- .../spanner/it/ITCommitTimestampTest.java | 4 +- .../cloud/spanner/it/ITPgJsonbTest.java | 2 +- .../cloud/spanner/it/ITPgNumericTest.java | 2 +- .../spanner/it/ITPitrCreateDatabaseTest.java | 2 +- .../spanner/it/ITPitrUpdateDatabaseTest.java | 2 +- .../spanner/spi/v1/GapicSpannerRpcTest.java | 4 +- 64 files changed, 577 insertions(+), 396 deletions(-) diff --git a/google-cloud-spanner-executor/pom.xml b/google-cloud-spanner-executor/pom.xml index c108b69b1a3..1c45d6915fd 100644 --- a/google-cloud-spanner-executor/pom.xml +++ b/google-cloud-spanner-executor/pom.xml @@ -145,10 +145,6 @@ com.google.api gax-grpc - - org.threeten - threetenbp - com.google.code.findbugs jsr305 diff --git a/google-cloud-spanner-executor/src/main/java/com/google/cloud/executor/spanner/CloudClientExecutor.java b/google-cloud-spanner-executor/src/main/java/com/google/cloud/executor/spanner/CloudClientExecutor.java index 481d95884ce..69c0d4d3ea9 100644 --- a/google-cloud-spanner-executor/src/main/java/com/google/cloud/executor/spanner/CloudClientExecutor.java +++ b/google-cloud-spanner-executor/src/main/java/com/google/cloud/executor/spanner/CloudClientExecutor.java @@ -170,6 +170,8 @@ import java.io.Serializable; import java.math.BigDecimal; import java.text.ParseException; +import java.time.Duration; +import java.time.LocalDate; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -186,8 +188,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import org.apache.commons.io.FileUtils; -import org.threeten.bp.Duration; -import org.threeten.bp.LocalDate; /** * Implementation of the SpannerExecutorProxy gRPC service that proxies action request through the @@ -818,13 +818,13 @@ private synchronized Spanner getClient(long timeoutSeconds, boolean useMultiplex } RetrySettings retrySettings = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofSeconds(1)) + .setInitialRetryDelayDuration(Duration.ofSeconds(1)) .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofSeconds(32)) - .setInitialRpcTimeout(rpcTimeout) + .setMaxRetryDelayDuration(Duration.ofSeconds(32)) + .setInitialRpcTimeoutDuration(rpcTimeout) .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(rpcTimeout) - .setTotalTimeout(rpcTimeout) + .setMaxRpcTimeoutDuration(rpcTimeout) + .setTotalTimeoutDuration(rpcTimeout) .build(); com.google.cloud.spanner.SessionPoolOptions.Builder poolOptionsBuilder = diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Clock.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Clock.java index 4fbe841cd84..567ccc1a043 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Clock.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Clock.java @@ -16,7 +16,7 @@ package com.google.cloud.spanner; -import org.threeten.bp.Instant; +import java.time.Instant; /** * Wrapper around current time so that we can fake it in tests. TODO(user): Replace with Java 8 diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/CompositeTracer.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/CompositeTracer.java index 050116af8de..60d7081cc1e 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/CompositeTracer.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/CompositeTracer.java @@ -16,15 +16,17 @@ package com.google.cloud.spanner; +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration; + import com.google.api.core.InternalApi; import com.google.api.gax.tracing.ApiTracer; import com.google.api.gax.tracing.BaseApiTracer; import com.google.api.gax.tracing.MetricsTracer; import com.google.common.collect.ImmutableList; +import java.time.Duration; import java.util.ArrayList; import java.util.List; import java.util.Map; -import org.threeten.bp.Duration; @InternalApi public class CompositeTracer extends BaseApiTracer { @@ -109,14 +111,14 @@ public void attemptCancelled() { } @Override - public void attemptFailed(Throwable error, Duration delay) { + public void attemptFailed(Throwable error, org.threeten.bp.Duration delay) { for (ApiTracer child : children) { - child.attemptFailed(error, delay); + child.attemptFailedDuration(error, toJavaTimeDuration(delay)); } } @Override - public void attemptFailedDuration(Throwable error, java.time.Duration delay) { + public void attemptFailedDuration(Throwable error, Duration delay) { for (ApiTracer child : children) { child.attemptFailedDuration(error, delay); } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/GrpcStreamIterator.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/GrpcStreamIterator.java index 79c02eab58c..60a52b78f25 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/GrpcStreamIterator.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/GrpcStreamIterator.java @@ -24,6 +24,7 @@ import com.google.common.collect.AbstractIterator; import com.google.common.util.concurrent.Uninterruptibles; import com.google.spanner.v1.PartialResultSet; +import java.time.Duration; import java.util.Optional; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; @@ -31,7 +32,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import javax.annotation.Nullable; -import org.threeten.bp.Duration; /** Adapts a streaming read/query call into an iterator over partial result sets. */ @VisibleForTesting @@ -77,7 +77,8 @@ public void setCall(SpannerRpc.StreamingCall call, boolean withBeginTransaction) this.call = call; this.withBeginTransaction = withBeginTransaction; ApiCallContext callContext = call.getCallContext(); - Duration streamWaitTimeout = callContext == null ? null : callContext.getStreamWaitTimeout(); + Duration streamWaitTimeout = + callContext == null ? null : callContext.getStreamWaitTimeoutDuration(); if (streamWaitTimeout != null) { // Determine the timeout unit to use. This reduces the precision to seconds if the timeout // value is more than 1 second, which is lower than the precision that would normally be diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/LatencyTest.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/LatencyTest.java index 4f70c32d2b4..2ba2f8c5a62 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/LatencyTest.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/LatencyTest.java @@ -19,11 +19,11 @@ import com.google.cloud.spanner.SpannerOptions.FixedCloseableExecutorProvider; import java.nio.file.Files; import java.nio.file.Paths; +import java.time.Duration; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadLocalRandom; -import org.threeten.bp.Duration; public class LatencyTest { @@ -42,7 +42,7 @@ public static void main(String[] args) throws Exception { Paths.get("/Users/loite/Downloads/appdev-soda-spanner-staging.json")))) .setSessionPoolOption( SessionPoolOptions.newBuilder() - .setWaitForMinSessions(Duration.ofSeconds(5L)) + .setWaitForMinSessionsDuration(Duration.ofSeconds(5L)) // .setUseMultiplexedSession(true) .build()) .setUseVirtualThreads(true) diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClient.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClient.java index 71e364bde83..bd709adbd99 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClient.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClient.java @@ -275,7 +275,7 @@ public void onSessionCreateFailure(Throwable t, int createFailureForSessionCount private static void maybeWaitForSessionCreation( SessionPoolOptions sessionPoolOptions, ApiFuture future) { - org.threeten.bp.Duration waitDuration = sessionPoolOptions.getWaitForMinSessions(); + Duration waitDuration = sessionPoolOptions.getWaitForMinSessions(); if (waitDuration != null && !waitDuration.isZero()) { long timeoutMillis = waitDuration.toMillis(); try { diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/OpenTelemetryApiTracer.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/OpenTelemetryApiTracer.java index 8d28a4b01ce..863c531de30 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/OpenTelemetryApiTracer.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/OpenTelemetryApiTracer.java @@ -16,6 +16,9 @@ package com.google.cloud.spanner; +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration; + +import com.google.api.core.ObsoleteApi; import com.google.api.gax.tracing.ApiTracer; import com.google.api.gax.tracing.ApiTracerFactory.OperationType; import com.google.common.base.Preconditions; @@ -24,10 +27,10 @@ import io.opentelemetry.api.common.AttributesBuilder; import io.opentelemetry.api.trace.Span; import io.opentelemetry.api.trace.StatusCode; +import java.time.Duration; import java.util.concurrent.atomic.AtomicLong; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.threeten.bp.Duration; /** * {@link com.google.api.gax.tracing.ApiTracer} for use with OpenTelemetry. Based on {@link @@ -163,8 +166,15 @@ public void attemptCancelled() { lastConnectionId = null; } + /** This method is obsolete. Use {@link #attemptFailedDuration(Throwable, Duration)} instead. */ + @Override + @ObsoleteApi("Use attemptFailedDuration(Throwable, Duration) instead") + public void attemptFailed(Throwable error, org.threeten.bp.Duration delay) { + attemptFailedDuration(error, toJavaTimeDuration(delay)); + } + @Override - public void attemptFailed(Throwable error, Duration delay) { + public void attemptFailedDuration(Throwable error, Duration delay) { AttributesBuilder builder = baseAttemptAttributesBuilder(); if (delay != null) { builder.put(RETRY_DELAY_KEY, delay.toMillis()); diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Operation.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Operation.java index f8f9d1e9779..66b1165f4a9 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Operation.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Operation.java @@ -28,9 +28,9 @@ import com.google.longrunning.Operation.ResultCase; import com.google.protobuf.Any; import com.google.rpc.Status; +import java.time.Duration; import java.util.concurrent.ExecutionException; import javax.annotation.Nullable; -import org.threeten.bp.Duration; /** * Represents a long-running operation. @@ -43,11 +43,11 @@ public class Operation { private final RetrySettings DEFAULT_OPERATION_WAIT_SETTINGS = RetrySettings.newBuilder() - .setTotalTimeout(Duration.ofHours(12L)) - .setInitialRetryDelay(Duration.ofMillis(500L)) + .setTotalTimeoutDuration(Duration.ofHours(12L)) + .setInitialRetryDelayDuration(Duration.ofMillis(500L)) .setRetryDelayMultiplier(1.0) .setJittered(false) - .setMaxRetryDelay(Duration.ofMinutes(500L)) + .setMaxRetryDelayDuration(Duration.ofMinutes(500L)) .build(); interface Parser { diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/PartitionedDmlTransaction.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/PartitionedDmlTransaction.java index 82b7f06b7d2..93cebb6333c 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/PartitionedDmlTransaction.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/PartitionedDmlTransaction.java @@ -39,12 +39,12 @@ import com.google.spanner.v1.TransactionOptions; import com.google.spanner.v1.TransactionSelector; import io.grpc.Status; +import java.time.Duration; +import java.time.temporal.ChronoUnit; import java.util.Map; import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; -import org.threeten.bp.Duration; -import org.threeten.bp.temporal.ChronoUnit; @InternalApi public class PartitionedDmlTransaction implements SessionImpl.SessionTransaction { diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionImpl.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionImpl.java index 5bd31603685..2f0d86b6314 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionImpl.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionImpl.java @@ -45,13 +45,13 @@ import com.google.spanner.v1.RequestOptions; import com.google.spanner.v1.Transaction; import com.google.spanner.v1.TransactionOptions; +import java.time.Instant; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; import java.util.concurrent.ExecutionException; import javax.annotation.Nullable; -import org.threeten.bp.Instant; /** * Implementation of {@link Session}. Sessions are managed internally by the client library, and @@ -203,7 +203,7 @@ public long executePartitionedUpdate(Statement stmt, UpdateOption... options) { PartitionedDmlTransaction txn = new PartitionedDmlTransaction(this, spanner.getRpc(), Ticker.systemTicker()); return txn.executeStreamingPartitionedUpdate( - stmt, spanner.getOptions().getPartitionedDmlTimeout(), options); + stmt, spanner.getOptions().getPartitionedDmlTimeoutDuration(), options); } @Override diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java index cf50fa44c77..aba6aee1db8 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java @@ -91,6 +91,8 @@ import io.opentelemetry.api.metrics.Meter; import java.io.PrintWriter; import java.io.StringWriter; +import java.time.Duration; +import java.time.Instant; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; @@ -115,8 +117,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.concurrent.GuardedBy; -import org.threeten.bp.Duration; -import org.threeten.bp.Instant; /** * Maintains a pool of sessions. This class itself is thread safe and is meant to be used @@ -2079,7 +2079,7 @@ private void removeIdleSessions(Instant currTime) { // Determine the minimum last use time for a session to be deemed to still be alive. Remove // all sessions that have a lastUseTime before that time, unless it would cause us to go // below MinSessions. - Instant minLastUseTime = currTime.minus(options.getRemoveInactiveSessionAfter()); + Instant minLastUseTime = currTime.minus(options.getRemoveInactiveSessionAfterDuration()); Iterator iterator = sessions.descendingIterator(); while (iterator.hasNext()) { PooledSession session = iterator.next(); diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java index 89de8df3ca9..d4f3e598b11 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java @@ -16,13 +16,17 @@ package com.google.cloud.spanner; +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration; +import static com.google.api.gax.util.TimeConversionUtils.toThreetenDuration; + import com.google.api.core.InternalApi; +import com.google.api.core.ObsoleteApi; import com.google.cloud.spanner.SessionPool.Position; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; +import java.time.Duration; import java.util.Locale; import java.util.Objects; -import org.threeten.bp.Duration; /** Options for the session pool used by {@code DatabaseClient}. */ public class SessionPoolOptions { @@ -48,7 +52,7 @@ public class SessionPoolOptions { private final ActionOnExhaustion actionOnExhaustion; private final long loopFrequency; - private final java.time.Duration multiplexedSessionMaintenanceLoopFrequency; + private final Duration multiplexedSessionMaintenanceLoopFrequency; private final int keepAliveIntervalMinutes; private final Duration removeInactiveSessionAfter; private final ActionOnSessionNotFound actionOnSessionNotFound; @@ -81,7 +85,6 @@ public class SessionPoolOptions { private final boolean useMultiplexedSessionForRW; - // TODO: Change to use java.time.Duration. private final Duration multiplexedSessionMaintenanceDuration; private SessionPoolOptions(Builder builder) { @@ -236,7 +239,7 @@ long getLoopFrequency() { return loopFrequency; } - java.time.Duration getMultiplexedSessionMaintenanceLoopFrequency() { + Duration getMultiplexedSessionMaintenanceLoopFrequency() { return this.multiplexedSessionMaintenanceLoopFrequency; } @@ -244,7 +247,13 @@ public int getKeepAliveIntervalMinutes() { return keepAliveIntervalMinutes; } - public Duration getRemoveInactiveSessionAfter() { + /** This method is obsolete. Use {@link #getRemoveInactiveSessionAfterDuration()} instead. */ + @ObsoleteApi("Use getRemoveInactiveSessionAfterDuration() instead") + public org.threeten.bp.Duration getRemoveInactiveSessionAfter() { + return toThreetenDuration(getRemoveInactiveSessionAfterDuration()); + } + + public Duration getRemoveInactiveSessionAfterDuration() { return removeInactiveSessionAfter; } @@ -548,8 +557,7 @@ public static class Builder { private InactiveTransactionRemovalOptions inactiveTransactionRemovalOptions = InactiveTransactionRemovalOptions.newBuilder().build(); private long loopFrequency = 10 * 1000L; - private java.time.Duration multiplexedSessionMaintenanceLoopFrequency = - java.time.Duration.ofMinutes(10); + private Duration multiplexedSessionMaintenanceLoopFrequency = Duration.ofMinutes(10); private int keepAliveIntervalMinutes = 30; private Duration removeInactiveSessionAfter = Duration.ofMinutes(55L); private boolean autoDetectDialect = false; @@ -678,7 +686,7 @@ Builder setLoopFrequency(long loopFrequency) { return this; } - Builder setMultiplexedSessionMaintenanceLoopFrequency(java.time.Duration frequency) { + Builder setMultiplexedSessionMaintenanceLoopFrequency(Duration frequency) { this.multiplexedSessionMaintenanceLoopFrequency = frequency; return this; } @@ -689,7 +697,16 @@ Builder setInactiveTransactionRemovalOptions( return this; } - public Builder setRemoveInactiveSessionAfter(Duration duration) { + /** + * This method is obsolete. Use {@link #setRemoveInactiveSessionAfterDuration(Duration)} + * instead. + */ + @ObsoleteApi("Use setRemoveInactiveSessionAfterDuration(Duration) instead") + public Builder setRemoveInactiveSessionAfter(org.threeten.bp.Duration duration) { + return setRemoveInactiveSessionAfterDuration(toJavaTimeDuration(duration)); + } + + public Builder setRemoveInactiveSessionAfterDuration(Duration duration) { this.removeInactiveSessionAfter = duration; return this; } @@ -720,7 +737,8 @@ public Builder setFailIfPoolExhausted() { * *

By default the requests are blocked for 60s and will fail with a `SpannerException` with * error code `ResourceExhausted` if this timeout is exceeded. If you wish to block for a - * different period use the option {@link Builder#setAcquireSessionTimeout(Duration)} ()} + * different period use the option {@link Builder#setAcquireSessionTimeoutDuration(Duration)} + * ()} */ public Builder setBlockIfPoolExhausted() { this.actionOnExhaustion = ActionOnExhaustion.BLOCK; @@ -908,6 +926,12 @@ public Builder setWriteSessionsFraction(float writeSessionsFraction) { return this; } + /** This method is obsolete. Use {@link #setWaitForMinSessionsDuration(Duration)} instead. */ + @ObsoleteApi("Use setWaitForMinSessionsDuration(Duration) instead") + public Builder setWaitForMinSessions(org.threeten.bp.Duration waitForMinSessions) { + return setWaitForMinSessionsDuration(toJavaTimeDuration(waitForMinSessions)); + } + /** * If greater than zero, waits for the session pool to have at least {@link * SessionPoolOptions#minSessions} before returning the database client to the caller. Note that @@ -918,16 +942,22 @@ public Builder setWriteSessionsFraction(float writeSessionsFraction) { * *

Defaults to zero (initialization is done asynchronously). */ - public Builder setWaitForMinSessions(Duration waitForMinSessions) { + public Builder setWaitForMinSessionsDuration(Duration waitForMinSessions) { this.waitForMinSessions = waitForMinSessions; return this; } + /** This method is obsolete. Use {@link #setAcquireSessionTimeoutDuration(Duration)} instead. */ + @ObsoleteApi("Use setAcquireSessionTimeoutDuration(Duration) instead") + public Builder setAcquireSessionTimeout(org.threeten.bp.Duration acquireSessionTimeout) { + return setAcquireSessionTimeoutDuration(toJavaTimeDuration(acquireSessionTimeout)); + } + /** * If greater than zero, we wait for said duration when no sessions are available in the {@link * SessionPool}. The default is a 60s timeout. Set the value to null to disable the timeout. */ - public Builder setAcquireSessionTimeout(Duration acquireSessionTimeout) { + public Builder setAcquireSessionTimeoutDuration(Duration acquireSessionTimeout) { try { if (acquireSessionTimeout != null) { Preconditions.checkArgument( diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionReference.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionReference.java index bc12cf8ee77..e96be9effaa 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionReference.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionReference.java @@ -20,9 +20,9 @@ import com.google.cloud.spanner.SessionClient.SessionId; import com.google.cloud.spanner.spi.v1.SpannerRpc; +import java.time.Instant; import java.util.Map; import javax.annotation.Nullable; -import org.threeten.bp.Instant; /** * A {@code Session} can be used to perform transactions that read and/or modify data in a Cloud diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerCloudMonitoringExporter.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerCloudMonitoringExporter.java index fc101fbcfc3..9337d04e531 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerCloudMonitoringExporter.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerCloudMonitoringExporter.java @@ -41,6 +41,7 @@ import io.opentelemetry.sdk.metrics.data.MetricData; import io.opentelemetry.sdk.metrics.export.MetricExporter; import java.io.IOException; +import java.time.Duration; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -49,7 +50,6 @@ import java.util.logging.Logger; import java.util.stream.Collectors; import javax.annotation.Nullable; -import org.threeten.bp.Duration; /** * Spanner Cloud Monitoring OpenTelemetry Exporter. @@ -85,10 +85,10 @@ static SpannerCloudMonitoringExporter create( settingsBuilder.setEndpoint(monitoringHost); } - org.threeten.bp.Duration timeout = Duration.ofMinutes(1); + Duration timeout = Duration.ofMinutes(1); // TODO: createServiceTimeSeries needs special handling if the request failed. Leaving // it as not retried for now. - settingsBuilder.createServiceTimeSeriesSettings().setSimpleTimeoutNoRetries(timeout); + settingsBuilder.createServiceTimeSeriesSettings().setSimpleTimeoutNoRetriesDuration(timeout); return new SpannerCloudMonitoringExporter( projectId, MetricServiceClient.create(settingsBuilder.build())); diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerImpl.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerImpl.java index dac1fc2c82b..1348d586e3a 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerImpl.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerImpl.java @@ -43,6 +43,7 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; import java.io.IOException; +import java.time.Instant; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -55,7 +56,6 @@ import java.util.logging.Logger; import javax.annotation.Nullable; import javax.annotation.concurrent.GuardedBy; -import org.threeten.bp.Instant; /** Default implementation of the Cloud Spanner interface. */ class SpannerImpl extends BaseService implements Spanner { diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java index d85b39c1253..7c232ddaa18 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java @@ -16,6 +16,9 @@ package com.google.cloud.spanner; +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration; +import static com.google.api.gax.util.TimeConversionUtils.toThreetenDuration; + import com.google.api.core.ApiFunction; import com.google.api.core.BetaApi; import com.google.api.core.InternalApi; @@ -74,6 +77,7 @@ import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; +import java.time.Duration; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -88,7 +92,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.concurrent.GuardedBy; -import org.threeten.bp.Duration; /** Options for the Cloud Spanner service. */ public class SpannerOptions extends ServiceOptions { @@ -380,116 +383,223 @@ public ApiCallContext configure( case BATCH_UPDATE: return batchUpdateTimeout == null ? null - : GrpcCallContext.createDefault().withTimeout(batchUpdateTimeout); + : GrpcCallContext.createDefault().withTimeoutDuration(batchUpdateTimeout); case COMMIT: return commitTimeout == null ? null - : GrpcCallContext.createDefault().withTimeout(commitTimeout); + : GrpcCallContext.createDefault().withTimeoutDuration(commitTimeout); case EXECUTE_QUERY: return executeQueryTimeout == null ? null : GrpcCallContext.createDefault() - .withTimeout(executeQueryTimeout) - .withStreamWaitTimeout(executeQueryTimeout); + .withTimeoutDuration(executeQueryTimeout) + .withStreamWaitTimeoutDuration(executeQueryTimeout); case EXECUTE_UPDATE: return executeUpdateTimeout == null ? null - : GrpcCallContext.createDefault().withTimeout(executeUpdateTimeout); + : GrpcCallContext.createDefault().withTimeoutDuration(executeUpdateTimeout); case PARTITION_QUERY: return partitionQueryTimeout == null ? null - : GrpcCallContext.createDefault().withTimeout(partitionQueryTimeout); + : GrpcCallContext.createDefault().withTimeoutDuration(partitionQueryTimeout); case PARTITION_READ: return partitionReadTimeout == null ? null - : GrpcCallContext.createDefault().withTimeout(partitionReadTimeout); + : GrpcCallContext.createDefault().withTimeoutDuration(partitionReadTimeout); case READ: return readTimeout == null ? null : GrpcCallContext.createDefault() - .withTimeout(readTimeout) - .withStreamWaitTimeout(readTimeout); + .withTimeoutDuration(readTimeout) + .withStreamWaitTimeoutDuration(readTimeout); case ROLLBACK: return rollbackTimeout == null ? null - : GrpcCallContext.createDefault().withTimeout(rollbackTimeout); + : GrpcCallContext.createDefault().withTimeoutDuration(rollbackTimeout); default: } return null; } - public Duration getCommitTimeout() { + /** This method is obsolete. Use {@link #getCommitTimeoutDuration()} instead. */ + @ObsoleteApi("Use getCommitTimeoutDuration() instead.") + public org.threeten.bp.Duration getCommitTimeout() { + return toThreetenDuration(getCommitTimeoutDuration()); + } + + public Duration getCommitTimeoutDuration() { return commitTimeout; } - public SpannerCallContextTimeoutConfigurator withCommitTimeout(Duration commitTimeout) { + /** This method is obsolete. Use {@link #withCommitTimeoutDuration(Duration)} instead. */ + @ObsoleteApi("Use withCommitTimeoutDuration() instead.") + public SpannerCallContextTimeoutConfigurator withCommitTimeout( + org.threeten.bp.Duration commitTimeout) { + return withCommitTimeoutDuration(toJavaTimeDuration(commitTimeout)); + } + + public SpannerCallContextTimeoutConfigurator withCommitTimeoutDuration(Duration commitTimeout) { this.commitTimeout = commitTimeout; return this; } - public Duration getRollbackTimeout() { + /** This method is obsolete. Use {@link #getRollbackTimeoutDuration()} instead. */ + @ObsoleteApi("Use getRollbackTimeoutDuration() instead.") + public org.threeten.bp.Duration getRollbackTimeout() { + return toThreetenDuration(getRollbackTimeoutDuration()); + } + + public Duration getRollbackTimeoutDuration() { return rollbackTimeout; } - public SpannerCallContextTimeoutConfigurator withRollbackTimeout(Duration rollbackTimeout) { + /** This method is obsolete. Use {@link #withRollbackTimeoutDuration(Duration)} instead. */ + @ObsoleteApi("Use withRollbackTimeoutDuration() instead.") + public SpannerCallContextTimeoutConfigurator withRollbackTimeout( + org.threeten.bp.Duration rollbackTimeout) { + return withRollbackTimeoutDuration(toJavaTimeDuration(rollbackTimeout)); + } + + public SpannerCallContextTimeoutConfigurator withRollbackTimeoutDuration( + Duration rollbackTimeout) { this.rollbackTimeout = rollbackTimeout; return this; } - public Duration getExecuteQueryTimeout() { + /** This method is obsolete. Use {@link #getExecuteQueryTimeoutDuration()} instead. */ + @ObsoleteApi("Use getExecuteQueryTimeoutDuration() instead.") + public org.threeten.bp.Duration getExecuteQueryTimeout() { + return toThreetenDuration(getExecuteQueryTimeoutDuration()); + } + + public Duration getExecuteQueryTimeoutDuration() { return executeQueryTimeout; } + /** This method is obsolete. Use {@link #withExecuteQueryTimeoutDuration(Duration)} instead. */ + @ObsoleteApi("Use withExecuteQueryTimeoutDuration() instead") public SpannerCallContextTimeoutConfigurator withExecuteQueryTimeout( + org.threeten.bp.Duration executeQueryTimeout) { + return withExecuteQueryTimeoutDuration(toJavaTimeDuration(executeQueryTimeout)); + } + + public SpannerCallContextTimeoutConfigurator withExecuteQueryTimeoutDuration( Duration executeQueryTimeout) { this.executeQueryTimeout = executeQueryTimeout; return this; } - public Duration getExecuteUpdateTimeout() { + /** This method is obsolete. Use {@link #getExecuteUpdateTimeoutDuration()} instead. */ + @ObsoleteApi("Use getExecuteUpdateTimeoutDuration() instead") + public org.threeten.bp.Duration getExecuteUpdateTimeout() { + return toThreetenDuration(getExecuteUpdateTimeoutDuration()); + } + + public Duration getExecuteUpdateTimeoutDuration() { return executeUpdateTimeout; } + /** This method is obsolete. Use {@link #withExecuteUpdateTimeoutDuration(Duration)} instead. */ + @ObsoleteApi("Use withExecuteUpdateTimeoutDuration() instead") public SpannerCallContextTimeoutConfigurator withExecuteUpdateTimeout( + org.threeten.bp.Duration executeUpdateTimeout) { + return withExecuteUpdateTimeoutDuration(toJavaTimeDuration(executeUpdateTimeout)); + } + + public SpannerCallContextTimeoutConfigurator withExecuteUpdateTimeoutDuration( Duration executeUpdateTimeout) { this.executeUpdateTimeout = executeUpdateTimeout; return this; } - public Duration getBatchUpdateTimeout() { + /** This method is obsolete. Use {@link #getBatchUpdateTimeoutDuration()} instead. */ + @ObsoleteApi("Use getBatchUpdateTimeoutDuration() instead") + public org.threeten.bp.Duration getBatchUpdateTimeout() { + return toThreetenDuration(getBatchUpdateTimeoutDuration()); + } + + public Duration getBatchUpdateTimeoutDuration() { return batchUpdateTimeout; } + /** This method is obsolete. Use {@link #withBatchUpdateTimeoutDuration(Duration)} instead. */ + @ObsoleteApi("Use withBatchUpdateTimeoutDuration() instead") public SpannerCallContextTimeoutConfigurator withBatchUpdateTimeout( + org.threeten.bp.Duration batchUpdateTimeout) { + return withBatchUpdateTimeoutDuration(toJavaTimeDuration(batchUpdateTimeout)); + } + + public SpannerCallContextTimeoutConfigurator withBatchUpdateTimeoutDuration( Duration batchUpdateTimeout) { this.batchUpdateTimeout = batchUpdateTimeout; return this; } - public Duration getReadTimeout() { + /** This method is obsolete. Use {@link #getReadTimeoutDuration()} instead. */ + @ObsoleteApi("Use getReadTimeoutDuration() instead") + public org.threeten.bp.Duration getReadTimeout() { + return toThreetenDuration(getReadTimeoutDuration()); + } + + public Duration getReadTimeoutDuration() { return readTimeout; } - public SpannerCallContextTimeoutConfigurator withReadTimeout(Duration readTimeout) { + /** This method is obsolete. Use {@link #withReadTimeoutDuration(Duration)} instead. */ + @ObsoleteApi("Use withReadTimeoutDuration() instead") + public SpannerCallContextTimeoutConfigurator withReadTimeout( + org.threeten.bp.Duration readTimeout) { + return withReadTimeoutDuration(toJavaTimeDuration(readTimeout)); + } + + public SpannerCallContextTimeoutConfigurator withReadTimeoutDuration(Duration readTimeout) { this.readTimeout = readTimeout; return this; } - public Duration getPartitionQueryTimeout() { + /** This method is obsolete. Use {@link #getPartitionQueryTimeoutDuration()} instead. */ + @ObsoleteApi("Use getPartitionQueryTimeoutDuration() instead") + public org.threeten.bp.Duration getPartitionQueryTimeout() { + return toThreetenDuration(getPartitionQueryTimeoutDuration()); + } + + public Duration getPartitionQueryTimeoutDuration() { return partitionQueryTimeout; } + /** + * This method is obsolete. Use {@link #withPartitionQueryTimeoutDuration(Duration)} instead. + */ + @ObsoleteApi("Use withPartitionQueryTimeoutDuration() instead") public SpannerCallContextTimeoutConfigurator withPartitionQueryTimeout( + org.threeten.bp.Duration partitionQueryTimeout) { + return withPartitionQueryTimeoutDuration(toJavaTimeDuration(partitionQueryTimeout)); + } + + public SpannerCallContextTimeoutConfigurator withPartitionQueryTimeoutDuration( Duration partitionQueryTimeout) { this.partitionQueryTimeout = partitionQueryTimeout; return this; } - public Duration getPartitionReadTimeout() { + /** This method is obsolete. Use {@link #getPartitionReadTimeoutDuration()} instead. */ + @ObsoleteApi("Use getPartitionReadTimeoutDuration() instead") + public org.threeten.bp.Duration getPartitionReadTimeout() { + return toThreetenDuration(getPartitionReadTimeoutDuration()); + } + + public Duration getPartitionReadTimeoutDuration() { return partitionReadTimeout; } + /** This method is obsolete. Use {@link #withPartitionReadTimeoutDuration(Duration)} instead. */ + @ObsoleteApi("Use withPartitionReadTimeoutDuration() instead") public SpannerCallContextTimeoutConfigurator withPartitionReadTimeout( + org.threeten.bp.Duration partitionReadTimeout) { + return withPartitionReadTimeoutDuration(toJavaTimeDuration(partitionReadTimeout)); + } + + public SpannerCallContextTimeoutConfigurator withPartitionReadTimeoutDuration( Duration partitionReadTimeout) { this.partitionReadTimeout = partitionReadTimeout; return this; @@ -785,9 +895,9 @@ public static class Builder static final DecodeMode DEFAULT_DECODE_MODE = DecodeMode.DIRECT; static final RetrySettings DEFAULT_ADMIN_REQUESTS_LIMIT_EXCEEDED_RETRY_SETTINGS = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofSeconds(5L)) + .setInitialRetryDelayDuration(Duration.ofSeconds(5L)) .setRetryDelayMultiplier(2.0) - .setMaxRetryDelay(Duration.ofSeconds(60L)) + .setMaxRetryDelayDuration(Duration.ofSeconds(60L)) .setMaxAttempts(10) .build(); private final ImmutableSet allowedClientLibTokens = @@ -851,13 +961,13 @@ protected Builder() { OperationTimedPollAlgorithm longRunningPollingAlgorithm = OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofSeconds(60L)) - .setMaxRpcTimeout(Duration.ofSeconds(600L)) - .setInitialRetryDelay(Duration.ofSeconds(20L)) - .setMaxRetryDelay(Duration.ofSeconds(45L)) + .setInitialRpcTimeoutDuration(Duration.ofSeconds(60L)) + .setMaxRpcTimeoutDuration(Duration.ofSeconds(600L)) + .setInitialRetryDelayDuration(Duration.ofSeconds(20L)) + .setMaxRetryDelayDuration(Duration.ofSeconds(45L)) .setRetryDelayMultiplier(1.5) .setRpcTimeoutMultiplier(1.5) - .setTotalTimeout(Duration.ofHours(48L)) + .setTotalTimeoutDuration(Duration.ofHours(48L)) .build()); databaseAdminStubSettingsBuilder .createDatabaseOperationSettings() @@ -1126,11 +1236,17 @@ public DatabaseAdminStubSettings.Builder getDatabaseAdminStubSettingsBuilder() { return databaseAdminStubSettingsBuilder; } + /** This method is obsolete. Use {@link #setPartitionedDmlTimeoutDuration(Duration)} instead. */ + @ObsoleteApi("Use setPartitionedDmlTimeoutDuration(Duration) instead") + public Builder setPartitionedDmlTimeout(org.threeten.bp.Duration timeout) { + return setPartitionedDmlTimeoutDuration(toJavaTimeDuration(timeout)); + } + /** * Sets a timeout specifically for Partitioned DML statements executed through {@link * DatabaseClient#executePartitionedUpdate(Statement, UpdateOption...)}. The default is 2 hours. */ - public Builder setPartitionedDmlTimeout(Duration timeout) { + public Builder setPartitionedDmlTimeoutDuration(Duration timeout) { this.partitionedDmlTimeout = timeout; return this; } @@ -1643,7 +1759,11 @@ public DatabaseAdminStubSettings getDatabaseAdminStubSettings() { return databaseAdminStubSettings; } - public Duration getPartitionedDmlTimeout() { + public org.threeten.bp.Duration getPartitionedDmlTimeout() { + return toThreetenDuration(getPartitionedDmlTimeoutDuration()); + } + + public Duration getPartitionedDmlTimeoutDuration() { return partitionedDmlTimeout; } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerRetryHelper.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerRetryHelper.java index a25c706e8a7..5fb35513222 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerRetryHelper.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerRetryHelper.java @@ -30,9 +30,9 @@ import com.google.common.base.Throwables; import com.google.spanner.v1.RollbackRequest; import io.grpc.Context; +import java.time.Duration; import java.util.concurrent.Callable; import java.util.concurrent.CancellationException; -import org.threeten.bp.Duration; /** * Util class for retrying aborted transactions. This class is a wrapper around {@link RetryHelper} @@ -60,7 +60,7 @@ class SpannerRetryHelper { .rollbackSettings() .getRetrySettings() .toBuilder() - .setTotalTimeout(Duration.ofHours(24L)) + .setTotalTimeoutDuration(Duration.ofHours(24L)) .setMaxAttempts(0) .build(); @@ -109,7 +109,7 @@ public TimedAttemptSettings createNextAttempt( if (retryDelay > -1L) { return prevSettings .toBuilder() - .setRandomizedRetryDelay(Duration.ofMillis(retryDelay)) + .setRandomizedRetryDelayDuration(Duration.ofMillis(retryDelay)) .build(); } } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/AbstractBaseUnitOfWork.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/AbstractBaseUnitOfWork.java index 58143523b65..f04026429f5 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/AbstractBaseUnitOfWork.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/AbstractBaseUnitOfWork.java @@ -368,7 +368,7 @@ public ApiCallContext configure( if (statementTimeout.hasTimeout() && applyStatementTimeoutToMethods.contains(method)) { return GrpcCallContext.createDefault() - .withTimeout(statementTimeout.asDuration()); + .withTimeoutDuration(statementTimeout.asDuration()); } return null; } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionImpl.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionImpl.java index 0b2d0b6b3a0..1b94702061c 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionImpl.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionImpl.java @@ -97,6 +97,7 @@ import java.io.FileInputStream; import java.io.InputStream; import java.time.Duration; +import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -114,7 +115,6 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.threeten.bp.Instant; /** Implementation for {@link Connection}, the generic Spanner connection API (not JDBC). */ class ConnectionImpl implements Connection { diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/LocalConnectionChecker.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/LocalConnectionChecker.java index 4271a8c2f0b..f9a12f5552a 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/LocalConnectionChecker.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/LocalConnectionChecker.java @@ -24,7 +24,7 @@ import com.google.cloud.spanner.admin.instance.v1.stub.GrpcInstanceAdminStub; import com.google.cloud.spanner.admin.instance.v1.stub.InstanceAdminStubSettings; import com.google.spanner.admin.instance.v1.ListInstanceConfigsRequest; -import org.threeten.bp.Duration; +import java.time.Duration; /** * Util class for quickly checking whether a local emulator or test server can be found. A common @@ -66,7 +66,7 @@ void checkLocalConnection(ConnectionOptions options) { .build()); testEmulatorSettings .listInstanceConfigsSettings() - .setSimpleTimeoutNoRetries(Duration.ofSeconds(10L)); + .setSimpleTimeoutNoRetriesDuration(Duration.ofSeconds(10L)); try (GrpcInstanceAdminStub stub = GrpcInstanceAdminStub.create(testEmulatorSettings.build())) { stub.listInstanceConfigsCallable() diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/StatementExecutor.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/StatementExecutor.java index a126bd8ff37..b92e575a047 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/StatementExecutor.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/StatementExecutor.java @@ -29,6 +29,7 @@ import com.google.common.util.concurrent.MoreExecutors; import com.google.protobuf.Duration; import io.opentelemetry.context.Context; +import java.time.temporal.ChronoUnit; import java.util.Collections; import java.util.List; import java.util.concurrent.Callable; @@ -37,7 +38,6 @@ import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import org.threeten.bp.temporal.ChronoUnit; /** * {@link StatementExecutor} is responsible for executing statements on a {@link Connection}. @@ -106,26 +106,26 @@ public boolean hasDuration() { }); } - org.threeten.bp.Duration asDuration() { + java.time.Duration asDuration() { if (!hasTimeout()) { - return org.threeten.bp.Duration.ZERO; + return java.time.Duration.ZERO; } TimeUnit unit = getAppropriateTimeUnit(); switch (unit) { case DAYS: - return org.threeten.bp.Duration.ofDays(getTimeoutValue(unit)); + return java.time.Duration.ofDays(getTimeoutValue(unit)); case HOURS: - return org.threeten.bp.Duration.ofHours(getTimeoutValue(unit)); + return java.time.Duration.ofHours(getTimeoutValue(unit)); case MICROSECONDS: - return org.threeten.bp.Duration.of(getTimeoutValue(unit), ChronoUnit.MICROS); + return java.time.Duration.of(getTimeoutValue(unit), ChronoUnit.MICROS); case MILLISECONDS: - return org.threeten.bp.Duration.ofMillis(getTimeoutValue(unit)); + return java.time.Duration.ofMillis(getTimeoutValue(unit)); case MINUTES: - return org.threeten.bp.Duration.ofMinutes(getTimeoutValue(unit)); + return java.time.Duration.ofMinutes(getTimeoutValue(unit)); case NANOSECONDS: - return org.threeten.bp.Duration.ofNanos(getTimeoutValue(unit)); + return java.time.Duration.ofNanos(getTimeoutValue(unit)); case SECONDS: - return org.threeten.bp.Duration.ofSeconds(getTimeoutValue(unit)); + return java.time.Duration.ofSeconds(getTimeoutValue(unit)); default: throw new IllegalStateException("invalid time unit: " + unit); } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java index fe23b097982..0e540ea7926 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java @@ -192,6 +192,7 @@ import java.net.URLDecoder; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; +import java.time.Duration; import java.util.Comparator; import java.util.HashMap; import java.util.List; @@ -214,7 +215,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.Nullable; -import org.threeten.bp.Duration; /** Implementation of Cloud Spanner remote calls using Gapic libraries. */ @InternalApi @@ -347,7 +347,7 @@ public GapicSpannerRpc(final SpannerOptions options) { // Set a keepalive time of 120 seconds to help long running // commit GRPC calls succeed - .setKeepAliveTime(Duration.ofSeconds(GRPC_KEEPALIVE_SECONDS)) + .setKeepAliveTimeDuration(Duration.ofSeconds(GRPC_KEEPALIVE_SECONDS)) // Then check if SpannerOptions provides an InterceptorProvider. Create a default // SpannerInterceptorProvider if none is provided @@ -396,7 +396,7 @@ public GapicSpannerRpc(final SpannerOptions options) { WatchdogProvider watchdogProvider = InstantiatingWatchdogProvider.create() .withExecutor(spannerWatchdog) - .withCheckInterval(checkInterval) + .withCheckIntervalDuration(checkInterval) .withClock(NanoClock.getDefaultClock()); final String emulatorHost = System.getenv("SPANNER_EMULATOR_HOST"); @@ -652,7 +652,7 @@ private static void checkEmulatorConnection( .setCredentialsProvider(credentialsProvider); testEmulatorSettings .listInstanceConfigsSettings() - .setSimpleTimeoutNoRetries(Duration.ofSeconds(10L)); + .setSimpleTimeoutNoRetriesDuration(Duration.ofSeconds(10L)); try (GrpcInstanceAdminStub stub = GrpcInstanceAdminStub.create(testEmulatorSettings.build())) { stub.listInstanceConfigsCallable() @@ -685,9 +685,9 @@ private static boolean isEmulatorEnabled(SpannerOptions options, String emulator private static final RetrySettings ADMIN_REQUESTS_LIMIT_EXCEEDED_RETRY_SETTINGS = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofSeconds(5L)) + .setInitialRetryDelayDuration(Duration.ofSeconds(5L)) .setRetryDelayMultiplier(2.0) - .setMaxRetryDelay(Duration.ofSeconds(60L)) + .setMaxRetryDelayDuration(Duration.ofSeconds(60L)) .setMaxAttempts(10) .build(); @@ -1770,7 +1770,7 @@ public ServerStream executeStreamingPartitionedDml( SpannerGrpc.getExecuteStreamingSqlMethod(), true); // Override any timeout settings that might have been set on the call context. - context = context.withTimeout(timeout).withStreamWaitTimeout(timeout); + context = context.withTimeoutDuration(timeout).withStreamWaitTimeoutDuration(timeout); return partitionedDmlStub.executeStreamingSqlCallable().call(request, context); } @@ -2037,7 +2037,10 @@ GrpcCallContext newCallContext( context.withCallOptions(context.getCallOptions().withCallCredentials(callCredentials)); } } - context = context.withStreamWaitTimeout(waitTimeout).withStreamIdleTimeout(idleTimeout); + context = + context + .withStreamWaitTimeoutDuration(waitTimeout) + .withStreamIdleTimeoutDuration(idleTimeout); CallContextConfigurator configurator = SpannerOptions.CALL_CONTEXT_CONFIGURATOR_KEY.get(); ApiCallContext apiCallContextFromContext = null; if (configurator != null) { diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerRpc.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerRpc.java index 0b040df4197..9ad94204743 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerRpc.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerRpc.java @@ -56,11 +56,11 @@ import com.google.spanner.admin.instance.v1.UpdateInstanceConfigMetadata; import com.google.spanner.admin.instance.v1.UpdateInstanceMetadata; import com.google.spanner.v1.*; +import java.time.Duration; import java.util.List; import java.util.Map; import java.util.Set; import javax.annotation.Nullable; -import org.threeten.bp.Duration; /** * Abstracts remote calls to the Cloud Spanner service. Typically end-consumer code will never use diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BatchCreateSessionsSlowTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BatchCreateSessionsSlowTest.java index 4bcc5d07401..72d04d94614 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BatchCreateSessionsSlowTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BatchCreateSessionsSlowTest.java @@ -33,6 +33,7 @@ import io.grpc.Server; import io.grpc.inprocess.InProcessServerBuilder; import java.io.IOException; +import java.time.Duration; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Executors; @@ -46,7 +47,6 @@ import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @Category(SlowTest.class) @RunWith(JUnit4.class) @@ -127,7 +127,7 @@ public void testBatchCreateSessionsTimesOut_whenDeadlineExceeded() throws Except builder .getSpannerStubSettingsBuilder() .batchCreateSessionsSettings() - .setSimpleTimeoutNoRetries(Duration.ofMillis(100)); + .setSimpleTimeoutNoRetriesDuration(Duration.ofMillis(100)); try (Spanner spanner = builder.build().getService()) { DatabaseId databaseId = DatabaseId.of("my-project", "my-instance", "my-database"); @@ -168,7 +168,9 @@ public void testBatchCreateSessionsTimesOut_whenResourceExhausted() throws Excep // Add a timeout for the max amount of time (60ms) that a request waits when a session is // unavailable. SessionPoolOptions sessionPoolOptions = - SessionPoolOptions.newBuilder().setAcquireSessionTimeout(Duration.ofMillis(60)).build(); + SessionPoolOptions.newBuilder() + .setAcquireSessionTimeoutDuration(Duration.ofMillis(60)) + .build(); SpannerOptions.Builder builder = SpannerOptions.newBuilder() .setProjectId("my-project") @@ -181,7 +183,7 @@ public void testBatchCreateSessionsTimesOut_whenResourceExhausted() throws Excep builder .getSpannerStubSettingsBuilder() .batchCreateSessionsSettings() - .setSimpleTimeoutNoRetries(Duration.ofMillis(1000)); + .setSimpleTimeoutNoRetriesDuration(Duration.ofMillis(1000)); try (Spanner spanner = builder.build().getService()) { DatabaseId databaseId = DatabaseId.of("my-project", "my-instance", "my-database"); @@ -192,7 +194,6 @@ public void testBatchCreateSessionsTimesOut_whenResourceExhausted() throws Excep List> futures = new ArrayList<>(5000); AtomicInteger counter = new AtomicInteger(); for (int i = 0; i < 5000; i++) { - final int index = i; futures.add( service.submit( () -> { diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/CloseSpannerWithOpenResultSetTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/CloseSpannerWithOpenResultSetTest.java index 8d622579714..c8228e5ecf8 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/CloseSpannerWithOpenResultSetTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/CloseSpannerWithOpenResultSetTest.java @@ -30,6 +30,7 @@ import com.google.spanner.v1.ExecuteSqlRequest; import io.grpc.ManagedChannelBuilder; import io.grpc.Status; +import java.time.Duration; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutorService; @@ -44,7 +45,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class CloseSpannerWithOpenResultSetTest extends AbstractMockServerTest { @@ -56,7 +56,9 @@ Spanner createSpanner() { .setChannelConfigurator(ManagedChannelBuilder::usePlaintext) .setCredentials(NoCredentials.getInstance()) .setSessionPoolOption( - SessionPoolOptions.newBuilder().setWaitForMinSessions(Duration.ofSeconds(5L)).build()) + SessionPoolOptions.newBuilder() + .setWaitForMinSessionsDuration(Duration.ofSeconds(5L)) + .build()) .build() .getService(); } diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/CompositeTracerTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/CompositeTracerTest.java index dfb7b252268..7f2e7fffc6f 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/CompositeTracerTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/CompositeTracerTest.java @@ -27,6 +27,7 @@ import com.google.common.collect.ImmutableList; import com.google.spanner.v1.ReadRequest; import java.lang.reflect.Method; +import java.time.Duration; import java.util.Arrays; import java.util.HashSet; import java.util.List; @@ -40,7 +41,6 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class CompositeTracerTest { @@ -150,11 +150,11 @@ public void testAttemptCancelled() { public void testAttemptFailed() { RuntimeException error = new RuntimeException(); Duration delay = Duration.ofMillis(10); - compositeTracer.attemptFailed(error, delay); - verify(child1, times(1)).attemptFailed(error, delay); - verify(child2, times(1)).attemptFailed(error, delay); - verify(child3, times(1)).attemptFailed(error, delay); - verify(child4, times(1)).attemptFailed(error, delay); + compositeTracer.attemptFailedDuration(error, delay); + verify(child1, times(1)).attemptFailedDuration(error, delay); + verify(child2, times(1)).attemptFailedDuration(error, delay); + verify(child3, times(1)).attemptFailedDuration(error, delay); + verify(child4, times(1)).attemptFailedDuration(error, delay); } @Test diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseAdminClientTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseAdminClientTest.java index 8bb644e75ce..e93066f2683 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseAdminClientTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseAdminClientTest.java @@ -55,6 +55,7 @@ import io.grpc.netty.shaded.io.grpc.netty.NettyServerBuilder; import io.grpc.protobuf.lite.ProtoLiteUtils; import java.net.InetSocketAddress; +import java.time.Duration; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -68,7 +69,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class DatabaseAdminClientTest { @@ -107,13 +107,13 @@ public static void startStaticServer() throws Exception { SpannerOptions.Builder builder = SpannerOptions.newBuilder(); RetrySettings longRunningInitialRetrySettings = RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(600L)) - .setMaxRpcTimeout(Duration.ofMillis(6000L)) - .setInitialRetryDelay(Duration.ofMillis(20L)) - .setMaxRetryDelay(Duration.ofMillis(45L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(600L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(6000L)) + .setInitialRetryDelayDuration(Duration.ofMillis(20L)) + .setMaxRetryDelayDuration(Duration.ofMillis(45L)) .setRetryDelayMultiplier(1.5) .setRpcTimeoutMultiplier(1.5) - .setTotalTimeout(Duration.ofMinutes(48L)) + .setTotalTimeoutDuration(Duration.ofMinutes(48L)) .build(); builder .getDatabaseAdminStubSettingsBuilder() @@ -128,12 +128,12 @@ public static void startStaticServer() throws Exception { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(20L)) - .setInitialRetryDelay(Duration.ofMillis(10L)) - .setMaxRetryDelay(Duration.ofMillis(150L)) - .setMaxRpcTimeout(Duration.ofMillis(150L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(20L)) + .setInitialRetryDelayDuration(Duration.ofMillis(10L)) + .setMaxRetryDelayDuration(Duration.ofMillis(150L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(150L)) .setMaxAttempts(10) - .setTotalTimeout(Duration.ofMillis(5000L)) + .setTotalTimeoutDuration(Duration.ofMillis(5000L)) .setRetryDelayMultiplier(1.3) .setRpcTimeoutMultiplier(1.3) .build())); @@ -152,12 +152,12 @@ public static void startStaticServer() throws Exception { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(20L)) - .setInitialRetryDelay(Duration.ofMillis(10L)) - .setMaxRetryDelay(Duration.ofMillis(150L)) - .setMaxRpcTimeout(Duration.ofMillis(150L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(20L)) + .setInitialRetryDelayDuration(Duration.ofMillis(10L)) + .setMaxRetryDelayDuration(Duration.ofMillis(150L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(150L)) .setMaxAttempts(10) - .setTotalTimeout(Duration.ofMillis(5000L)) + .setTotalTimeoutDuration(Duration.ofMillis(5000L)) .setRetryDelayMultiplier(1.3) .setRpcTimeoutMultiplier(1.3) .build())); @@ -175,19 +175,19 @@ public static void startStaticServer() throws Exception { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(20L)) - .setInitialRetryDelay(Duration.ofMillis(10L)) - .setMaxRetryDelay(Duration.ofMillis(150L)) - .setMaxRpcTimeout(Duration.ofMillis(150L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(20L)) + .setInitialRetryDelayDuration(Duration.ofMillis(10L)) + .setMaxRetryDelayDuration(Duration.ofMillis(150L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(150L)) .setMaxAttempts(10) - .setTotalTimeout(Duration.ofMillis(5000L)) + .setTotalTimeoutDuration(Duration.ofMillis(5000L)) .setRetryDelayMultiplier(1.3) .setRpcTimeoutMultiplier(1.3) .build())); builder.setRetryAdministrativeRequestsSettings( SpannerOptions.Builder.DEFAULT_ADMIN_REQUESTS_LIMIT_EXCEEDED_RETRY_SETTINGS .toBuilder() - .setInitialRetryDelay(Duration.ofNanos(1L)) + .setInitialRetryDelayDuration(Duration.ofNanos(1L)) .build()); spanner = builder diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseAdminGaxTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseAdminGaxTest.java index 0af51744abd..be9f07d7f79 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseAdminGaxTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseAdminGaxTest.java @@ -37,6 +37,7 @@ import io.grpc.StatusRuntimeException; import io.grpc.inprocess.InProcessServerBuilder; import java.io.IOException; +import java.time.Duration; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -56,7 +57,6 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; -import org.threeten.bp.Duration; @RunWith(Parameterized.class) public class DatabaseAdminGaxTest { @@ -214,22 +214,22 @@ public void setUp() throws Exception { mockDatabaseAdmin.reset(); RetrySettings retrySettingsWithLowTimeout = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(1L)) - .setMaxRetryDelay(Duration.ofMillis(1L)) - .setInitialRpcTimeout(Duration.ofMillis(20L)) - .setMaxRpcTimeout(Duration.ofMillis(1000L)) + .setInitialRetryDelayDuration(Duration.ofMillis(1L)) + .setMaxRetryDelayDuration(Duration.ofMillis(1L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(20L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(1000L)) .setRetryDelayMultiplier(2.0) .setMaxAttempts(10) - .setTotalTimeout(Duration.ofMillis(200L)) + .setTotalTimeoutDuration(Duration.ofMillis(200L)) .build(); RetrySettings retrySettingsWithHighTimeout = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(1L)) - .setMaxRetryDelay(Duration.ofMillis(1L)) - .setInitialRpcTimeout(Duration.ofMillis(2000L)) - .setMaxRpcTimeout(Duration.ofMillis(5000L)) + .setInitialRetryDelayDuration(Duration.ofMillis(1L)) + .setMaxRetryDelayDuration(Duration.ofMillis(1L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(2000L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(5000L)) .setMaxAttempts(3) - .setTotalTimeout(Duration.ofMillis(15000L)) + .setTotalTimeoutDuration(Duration.ofMillis(15000L)) .build(); final RetrySettings retrySettingsToUse = exceptionType == ExceptionType.DELAYED diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java index 62a10c0adb4..86d0bfc2c94 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java @@ -111,6 +111,8 @@ import io.opentelemetry.api.OpenTelemetry; import java.io.IOException; import java.nio.charset.StandardCharsets; +import java.time.Duration; +import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; import java.util.Base64; @@ -135,8 +137,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; -import org.threeten.bp.Instant; @RunWith(JUnit4.class) public class DatabaseClientImplTest { @@ -2852,10 +2852,10 @@ public void testPartitionedDmlDoesNotTimeout() { mockSpanner.setExecuteSqlExecutionTime(SimulatedExecutionTime.ofMinimumAndRandomTime(20, 0)); final RetrySettings retrySettings = RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(1L)) - .setMaxRpcTimeout(Duration.ofMillis(1L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(1L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(1L)) .setMaxAttempts(1) - .setTotalTimeout(Duration.ofMillis(1L)) + .setTotalTimeoutDuration(Duration.ofMillis(1L)) .build(); SpannerOptions.Builder builder = SpannerOptions.newBuilder() @@ -2868,7 +2868,8 @@ public void testPartitionedDmlDoesNotTimeout() { DatabaseClient client = spanner.getDatabaseClient(DatabaseId.of(TEST_PROJECT, TEST_INSTANCE, TEST_DATABASE)); - assertThat(spanner.getOptions().getPartitionedDmlTimeout()).isEqualTo(Duration.ofHours(2L)); + assertThat(spanner.getOptions().getPartitionedDmlTimeoutDuration()) + .isEqualTo(Duration.ofHours(2L)); // PDML should not timeout with these settings. long updateCount = client.executePartitionedUpdate(UPDATE_STATEMENT); @@ -2900,11 +2901,12 @@ public void testPartitionedDmlWithLowerTimeout() { .setChannelProvider(channelProvider) .setCredentials(NoCredentials.getInstance()); // Set PDML timeout value. - builder.setPartitionedDmlTimeout(Duration.ofMillis(10L)); + builder.setPartitionedDmlTimeoutDuration(Duration.ofMillis(10L)); try (Spanner spanner = builder.build().getService()) { DatabaseClient client = spanner.getDatabaseClient(DatabaseId.of(TEST_PROJECT, TEST_INSTANCE, TEST_DATABASE)); - assertThat(spanner.getOptions().getPartitionedDmlTimeout()).isEqualTo(Duration.ofMillis(10L)); + assertThat(spanner.getOptions().getPartitionedDmlTimeoutDuration()) + .isEqualTo(Duration.ofMillis(10L)); // PDML should time out with these settings. mockSpanner.setExecuteSqlExecutionTime( SimulatedExecutionTime.ofMinimumAndRandomTime(1000, 0)); @@ -2933,7 +2935,7 @@ public void testPartitionedDmlWithHigherTimeout() { .setChannelProvider(channelProvider) .setCredentials(NoCredentials.getInstance()); // Set PDML timeout value to a value that should allow the statement to be executed. - builder.setPartitionedDmlTimeout(Duration.ofMillis(5000L)); + builder.setPartitionedDmlTimeoutDuration(Duration.ofMillis(5000L)); // Set the ExecuteSql RPC timeout value to a value lower than the time needed to execute the // statement. The higher timeout value that is set above should be respected, and the value for // the ExecuteSQL RPC should be ignored specifically for Partitioned DML. @@ -2946,10 +2948,10 @@ public void testPartitionedDmlWithHigherTimeout() { .executeSqlSettings() .getRetrySettings() .toBuilder() - .setInitialRpcTimeout(Duration.ofMillis(10L)) - .setMaxRpcTimeout(Duration.ofMillis(10L)) - .setInitialRetryDelay(Duration.ofMillis(1L)) - .setMaxRetryDelay(Duration.ofMillis(1L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(10L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(10L)) + .setInitialRetryDelayDuration(Duration.ofMillis(1L)) + .setMaxRetryDelayDuration(Duration.ofMillis(1L)) .build()); try (Spanner spanner = builder.build().getService()) { DatabaseClient client = @@ -3051,7 +3053,7 @@ public void testDatabaseOrInstanceDoesNotExistOnCreate() { .setSessionPoolOption( SessionPoolOptions.newBuilder() .setMinSessions(0) - .setWaitForMinSessions(waitForMinSessions) + .setWaitForMinSessionsDuration(waitForMinSessions) .build()) .build() .getService()) { @@ -3737,7 +3739,9 @@ public void testBatchCreateSessionsPermissionDenied() { .setChannelProvider(channelProvider) .setCredentials(NoCredentials.getInstance()) .setSessionPoolOption( - SessionPoolOptions.newBuilder().setWaitForMinSessions(waitForMinSessions).build()) + SessionPoolOptions.newBuilder() + .setWaitForMinSessionsDuration(waitForMinSessions) + .build()) .build() .getService()) { DatabaseId databaseId = DatabaseId.of("my-project", "my-instance", "my-database"); @@ -3836,7 +3840,7 @@ public void testSpecificTimeout() { .withValue( SpannerOptions.CALL_CONTEXT_CONFIGURATOR_KEY, SpannerCallContextTimeoutConfigurator.create() - .withExecuteQueryTimeout(Duration.ofNanos(1L))) + .withExecuteQueryTimeoutDuration(Duration.ofNanos(1L))) .run( () -> { // Query should fail with a timeout. @@ -4956,7 +4960,7 @@ public void testStreamWaitTimeout() { @Override public ApiCallContext configure( ApiCallContext context, ReqT request, MethodDescriptor method) { - return context.withStreamWaitTimeout(Duration.ofNanos(1L)); + return context.withStreamWaitTimeoutDuration(Duration.ofNanos(1L)); } }; Context context = @@ -4983,7 +4987,7 @@ public void testZeroStreamWaitTimeout() { @Override public ApiCallContext configure( ApiCallContext context, ReqT request, MethodDescriptor method) { - return context.withStreamWaitTimeout(Duration.ZERO); + return context.withStreamWaitTimeoutDuration(Duration.ZERO); } }; Context context = @@ -5002,12 +5006,12 @@ public ApiCallContext configure( public void testRetryOnResourceExhausted() { final RetrySettings retrySettings = RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofSeconds(60L)) - .setMaxRpcTimeout(Duration.ofSeconds(60L)) - .setTotalTimeout(Duration.ofSeconds(60L)) + .setInitialRpcTimeoutDuration(Duration.ofSeconds(60L)) + .setMaxRpcTimeoutDuration(Duration.ofSeconds(60L)) + .setTotalTimeoutDuration(Duration.ofSeconds(60L)) .setRpcTimeoutMultiplier(1.0d) - .setInitialRetryDelay(Duration.ZERO) - .setMaxRetryDelay(Duration.ZERO) + .setInitialRetryDelayDuration(Duration.ZERO) + .setMaxRetryDelayDuration(Duration.ZERO) .setMaxAttempts(100) .build(); SpannerOptions.Builder builder = @@ -5096,7 +5100,7 @@ public void testSessionPoolExhaustedError_containsStackTraces() { .setFailIfPoolExhausted() .setMinSessions(2) .setMaxSessions(4) - .setWaitForMinSessions(Duration.ofSeconds(10L)) + .setWaitForMinSessionsDuration(Duration.ofSeconds(10L)) .build()) .build() .getService()) { diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DefaultBenchmark.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DefaultBenchmark.java index 7579c4328d2..35712cd5b4e 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DefaultBenchmark.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DefaultBenchmark.java @@ -92,7 +92,7 @@ public void setup() throws Exception { SessionPoolOptions.newBuilder() .setMinSessions(minSessions) .setMaxSessions(maxSessions) - .setWaitForMinSessions(org.threeten.bp.Duration.ofSeconds(20)) + .setWaitForMinSessionsDuration(Duration.ofSeconds(20)) .build()) .setHost(SERVER_URL) .setNumChannels(NUM_GRPC_CHANNELS) @@ -168,7 +168,7 @@ public void burstUpdates(final BenchmarkState server) throws Exception { collectResultsAndPrint(service, results, TOTAL_WRITES_PER_RUN); } - private List runBenchmarksForSingleUseQueries( + private List runBenchmarksForSingleUseQueries( final BenchmarkState server, int numberOfOperations) { List results = new ArrayList<>(numberOfOperations); // Execute one query to make sure everything has been warmed up. @@ -186,7 +186,7 @@ private void executeWarmup(final BenchmarkState server) { } } - private java.time.Duration executeSingleUseQuery(final BenchmarkState server) { + private Duration executeSingleUseQuery(final BenchmarkState server) { Stopwatch watch = Stopwatch.createStarted(); try (ResultSet rs = server.client.singleUse().executeQuery(getRandomisedReadStatement())) { @@ -198,7 +198,7 @@ private java.time.Duration executeSingleUseQuery(final BenchmarkState server) { return watch.elapsed(); } - private List runBenchmarkForUpdates( + private List runBenchmarkForUpdates( final BenchmarkState server, int numberOfOperations) { List results = new ArrayList<>(numberOfOperations); // Execute one query to make sure everything has been warmed up. @@ -237,7 +237,7 @@ void collectResultsAndPrint( List>> results, int numOperationsPerThread) throws Exception { - final List collectResults = + final List collectResults = collectResults( service, results, numOperationsPerThread * PARALLEL_THREADS, Duration.ofMinutes(60)); printResults(collectResults); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/FakeClock.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/FakeClock.java index d46618ce2d0..ab2e859adff 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/FakeClock.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/FakeClock.java @@ -15,8 +15,8 @@ */ package com.google.cloud.spanner; +import java.time.Instant; import java.util.concurrent.atomic.AtomicLong; -import org.threeten.bp.Instant; /** * Class which allows to mock {@link Clock} in unit tests and return custom time values within the diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/GrpcResultSetTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/GrpcResultSetTest.java index 59a18a3ab79..25c01560e92 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/GrpcResultSetTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/GrpcResultSetTest.java @@ -44,6 +44,7 @@ import com.google.spanner.v1.Transaction; import java.math.BigDecimal; import java.nio.charset.StandardCharsets; +import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; import java.util.Base64; @@ -55,7 +56,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; /** Unit tests for {@link GrpcResultSet}. */ @RunWith(JUnit4.class) @@ -90,7 +90,7 @@ public void setUp() { new SpannerRpc.StreamingCall() { @Override public ApiCallContext getCallContext() { - return GrpcCallContext.createDefault().withStreamWaitTimeout(streamWaitTimeout); + return GrpcCallContext.createDefault().withStreamWaitTimeoutDuration(streamWaitTimeout); } @Override diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/InstanceAdminGaxTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/InstanceAdminGaxTest.java index c5a317ce5d7..f619d9b461f 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/InstanceAdminGaxTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/InstanceAdminGaxTest.java @@ -44,6 +44,7 @@ import io.grpc.StatusRuntimeException; import io.grpc.inprocess.InProcessServerBuilder; import java.io.IOException; +import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -64,7 +65,6 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; -import org.threeten.bp.Duration; @RunWith(Parameterized.class) public class InstanceAdminGaxTest { @@ -221,23 +221,23 @@ public void setUp() throws Exception { mockInstanceAdmin.reset(); RetrySettings retrySettingsWithLowTimeout = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(1L)) - .setMaxRetryDelay(Duration.ofMillis(10L)) - .setInitialRpcTimeout(Duration.ofMillis(20L)) - .setMaxRpcTimeout(Duration.ofMillis(200L)) + .setInitialRetryDelayDuration(Duration.ofMillis(1L)) + .setMaxRetryDelayDuration(Duration.ofMillis(10L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(20L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(200L)) .setRetryDelayMultiplier(1.3d) .setMaxAttempts(10) - .setTotalTimeout(Duration.ofMillis(20000L)) + .setTotalTimeoutDuration(Duration.ofMillis(20000L)) .setJittered(false) .build(); RetrySettings retrySettingsWithHighTimeout = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(1L)) - .setMaxRetryDelay(Duration.ofMillis(1L)) - .setInitialRpcTimeout(Duration.ofMillis(2000L)) - .setMaxRpcTimeout(Duration.ofMillis(5000L)) + .setInitialRetryDelayDuration(Duration.ofMillis(1L)) + .setMaxRetryDelayDuration(Duration.ofMillis(1L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(2000L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(5000L)) .setMaxAttempts(3) - .setTotalTimeout(Duration.ofMillis(15000L)) + .setTotalTimeoutDuration(Duration.ofMillis(15000L)) .build(); final RetrySettings retrySettingsToUse = exceptionType == ExceptionType.DELAYED diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/LongRunningSessionsBenchmark.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/LongRunningSessionsBenchmark.java index 19d614ded07..58eb423a5db 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/LongRunningSessionsBenchmark.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/LongRunningSessionsBenchmark.java @@ -28,6 +28,7 @@ import com.google.common.util.concurrent.ListeningScheduledExecutorService; import com.google.common.util.concurrent.MoreExecutors; import com.google.spanner.v1.BatchCreateSessionsRequest; +import java.time.Duration; import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -48,7 +49,6 @@ import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; -import org.threeten.bp.Duration; /** * Benchmarks for long-running sessions scenarios. The simulated execution times are based on @@ -126,7 +126,7 @@ public void setup() throws Exception { SessionPoolOptions.newBuilder() .setMinSessions(minSessions) .setMaxSessions(maxSessions) - .setWaitForMinSessions(Duration.ofSeconds(5)) + .setWaitForMinSessionsDuration(Duration.ofSeconds(5)) .setInactiveTransactionRemovalOptions(inactiveTransactionRemovalOptions) .build()) .build(); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MockDatabaseAdminServiceImplTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MockDatabaseAdminServiceImplTest.java index 9c9f0e7f91a..637f97cb097 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MockDatabaseAdminServiceImplTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MockDatabaseAdminServiceImplTest.java @@ -58,6 +58,7 @@ import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; import com.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest; import java.io.IOException; +import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -74,7 +75,6 @@ import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class MockDatabaseAdminServiceImplTest { @@ -150,12 +150,12 @@ public void setUp() throws IOException { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(20L)) - .setInitialRetryDelay(Duration.ofMillis(10L)) - .setMaxRetryDelay(Duration.ofMillis(150L)) - .setMaxRpcTimeout(Duration.ofMillis(150L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(20L)) + .setInitialRetryDelayDuration(Duration.ofMillis(10L)) + .setMaxRetryDelayDuration(Duration.ofMillis(150L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(150L)) .setMaxAttempts(10) - .setTotalTimeout(Duration.ofMillis(5000L)) + .setTotalTimeoutDuration(Duration.ofMillis(5000L)) .setRetryDelayMultiplier(1.3) .setRpcTimeoutMultiplier(1.3) .build())); @@ -164,12 +164,12 @@ public void setUp() throws IOException { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(20L)) - .setInitialRetryDelay(Duration.ofMillis(10L)) - .setMaxRetryDelay(Duration.ofMillis(150L)) - .setMaxRpcTimeout(Duration.ofMillis(150L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(20L)) + .setInitialRetryDelayDuration(Duration.ofMillis(10L)) + .setMaxRetryDelayDuration(Duration.ofMillis(150L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(150L)) .setMaxAttempts(10) - .setTotalTimeout(Duration.ofMillis(5000L)) + .setTotalTimeoutDuration(Duration.ofMillis(5000L)) .setRetryDelayMultiplier(1.3) .setRpcTimeoutMultiplier(1.3) .build())); @@ -178,12 +178,12 @@ public void setUp() throws IOException { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(20L)) - .setInitialRetryDelay(Duration.ofMillis(10L)) - .setMaxRetryDelay(Duration.ofMillis(150L)) - .setMaxRpcTimeout(Duration.ofMillis(150L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(20L)) + .setInitialRetryDelayDuration(Duration.ofMillis(10L)) + .setMaxRetryDelayDuration(Duration.ofMillis(150L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(150L)) .setMaxAttempts(10) - .setTotalTimeout(Duration.ofMillis(5000L)) + .setTotalTimeoutDuration(Duration.ofMillis(5000L)) .setRetryDelayMultiplier(1.3) .setRpcTimeoutMultiplier(1.3) .build())); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MockSpannerServiceImpl.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MockSpannerServiceImpl.java index 39f1ff180fa..676cb05eb07 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MockSpannerServiceImpl.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MockSpannerServiceImpl.java @@ -86,6 +86,7 @@ import io.grpc.protobuf.lite.ProtoLiteUtils; import io.grpc.stub.StreamObserver; import java.math.BigDecimal; +import java.time.Instant; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -112,7 +113,6 @@ import java.util.concurrent.atomic.AtomicLong; import java.util.stream.Collectors; import java.util.stream.LongStream; -import org.threeten.bp.Instant; /** * In-process mock implementation of a Cloud Spanner server. The user must specify the results the diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClientMockServerTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClientMockServerTest.java index 4dc1da62e7b..9f3d0751471 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClientMockServerTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClientMockServerTest.java @@ -98,7 +98,7 @@ public void createSpannerInstance() { // Set the maintainer to loop once every 1ms .setMultiplexedSessionMaintenanceLoopFrequency(Duration.ofMillis(1L)) // Set multiplexed sessions to be replaced once every 1ms - .setMultiplexedSessionMaintenanceDuration(org.threeten.bp.Duration.ofMillis(1L)) + .setMultiplexedSessionMaintenanceDuration(Duration.ofMillis(1L)) .setFailOnSessionLeak() .build()) .build() diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClientTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClientTest.java index 287fdd0bd0b..9a43ad07cdf 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClientTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClientTest.java @@ -60,7 +60,7 @@ public void testMaintainer() { when(spanner.getOptions()).thenReturn(spannerOptions); when(spannerOptions.getSessionPoolOptions()).thenReturn(sessionPoolOptions); when(sessionPoolOptions.getMultiplexedSessionMaintenanceDuration()) - .thenReturn(org.threeten.bp.Duration.ofDays(7)); + .thenReturn(Duration.ofDays(7)); when(sessionPoolOptions.getMultiplexedSessionMaintenanceLoopFrequency()) .thenReturn(Duration.ofMinutes(10)); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionsBenchmark.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionsBenchmark.java index ff976141d96..c6f7e22f280 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionsBenchmark.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionsBenchmark.java @@ -95,7 +95,7 @@ public void setup() throws Exception { SessionPoolOptions.newBuilder() .setMinSessions(minSessions) .setMaxSessions(maxSessions) - .setWaitForMinSessions(org.threeten.bp.Duration.ofSeconds(20)) + .setWaitForMinSessionsDuration(Duration.ofSeconds(20)) .setUseMultiplexedSession(true) .build()) .setHost(SERVER_URL) @@ -132,7 +132,7 @@ public void burstQueries(final BenchmarkState server) throws Exception { collectResultsAndPrint(service, results, TOTAL_READS_PER_RUN); } - private List runBenchmarksForSingleUseQueries( + private List runBenchmarksForSingleUseQueries( final BenchmarkState server, int numberOfOperations) { List results = new ArrayList<>(numberOfOperations); // Execute one query to make sure everything has been warmed up. @@ -150,7 +150,7 @@ private void executeWarmup(final BenchmarkState server) { } } - private java.time.Duration executeSingleUseQuery(final BenchmarkState server) { + private Duration executeSingleUseQuery(final BenchmarkState server) { Stopwatch watch = Stopwatch.createStarted(); try (ResultSet rs = server.client.singleUse().executeQuery(getRandomisedReadStatement())) { @@ -175,7 +175,7 @@ void collectResultsAndPrint( List>> results, int numOperationsPerThread) throws Exception { - final List collectResults = + final List collectResults = collectResults( service, results, numOperationsPerThread * PARALLEL_THREADS, Duration.ofMinutes(60)); printResults(collectResults); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OpenCensusApiTracerTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OpenCensusApiTracerTest.java index 5e7a58cdb23..ad27c775729 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OpenCensusApiTracerTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OpenCensusApiTracerTest.java @@ -41,6 +41,7 @@ import io.opentelemetry.api.common.Attributes; import io.opentelemetry.sdk.trace.data.SpanData; import java.lang.reflect.Modifier; +import java.time.Duration; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -55,7 +56,6 @@ import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @Category(TracerTest.class) @RunWith(JUnit4.class) @@ -121,10 +121,10 @@ public void createSpannerInstance() { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofNanos(1L)) - .setMaxRetryDelay(Duration.ofNanos(1L)) + .setInitialRetryDelayDuration(Duration.ofNanos(1L)) + .setMaxRetryDelayDuration(Duration.ofNanos(1L)) .setRetryDelayMultiplier(1.0) - .setTotalTimeout(Duration.ofMinutes(10L)) + .setTotalTimeoutDuration(Duration.ofMinutes(10L)) .build())); spanner = builder @@ -133,7 +133,7 @@ public void createSpannerInstance() { .setCredentials(NoCredentials.getInstance()) .setSessionPoolOption( SessionPoolOptions.newBuilder() - .setWaitForMinSessions(Duration.ofSeconds(5L)) + .setWaitForMinSessionsDuration(Duration.ofSeconds(5L)) .setFailOnSessionLeak() .build()) .setEnableApiTracing(true) @@ -359,7 +359,7 @@ public boolean isEnableApiTracing() { .setCredentials(NoCredentials.getInstance()) .setSessionPoolOption( SessionPoolOptions.newBuilder() - .setWaitForMinSessions(Duration.ofSeconds(5L)) + .setWaitForMinSessionsDuration(Duration.ofSeconds(5L)) .setFailOnSessionLeak() .build()) .build() diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OpenTelemetryApiTracerTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OpenTelemetryApiTracerTest.java index 123f0f486a7..e4d25f1d9b3 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OpenTelemetryApiTracerTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OpenTelemetryApiTracerTest.java @@ -47,6 +47,7 @@ import io.opentelemetry.sdk.trace.data.EventData; import io.opentelemetry.sdk.trace.data.SpanData; import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor; +import java.time.Duration; import java.util.List; import java.util.Map.Entry; import java.util.Objects; @@ -58,7 +59,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class OpenTelemetryApiTracerTest extends AbstractMockServerTest { @@ -121,10 +121,10 @@ public void createSpannerInstance() { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofNanos(1L)) - .setMaxRetryDelay(Duration.ofNanos(1L)) + .setInitialRetryDelayDuration(Duration.ofNanos(1L)) + .setMaxRetryDelayDuration(Duration.ofNanos(1L)) .setRetryDelayMultiplier(1.0) - .setTotalTimeout(Duration.ofMinutes(10L)) + .setTotalTimeoutDuration(Duration.ofMinutes(10L)) .build())); spanner = builder @@ -133,7 +133,7 @@ public void createSpannerInstance() { .setCredentials(NoCredentials.getInstance()) .setSessionPoolOption( SessionPoolOptions.newBuilder() - .setWaitForMinSessions(Duration.ofSeconds(5L)) + .setWaitForMinSessionsDuration(Duration.ofSeconds(5L)) .setFailOnSessionLeak() .build()) .setEnableApiTracing(true) @@ -426,7 +426,7 @@ public boolean isEnableApiTracing() { .setCredentials(NoCredentials.getInstance()) .setSessionPoolOption( SessionPoolOptions.newBuilder() - .setWaitForMinSessions(Duration.ofSeconds(5L)) + .setWaitForMinSessionsDuration(Duration.ofSeconds(5L)) .setFailOnSessionLeak() .build()) .build() diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OpenTelemetryBuiltInMetricsTracerTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OpenTelemetryBuiltInMetricsTracerTest.java index 9f65402c31f..7a14681d525 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OpenTelemetryBuiltInMetricsTracerTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OpenTelemetryBuiltInMetricsTracerTest.java @@ -43,6 +43,7 @@ import io.opentelemetry.sdk.metrics.data.LongPointData; import io.opentelemetry.sdk.metrics.data.MetricData; import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader; +import java.time.Duration; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -55,7 +56,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class OpenTelemetryBuiltInMetricsTracerTest extends AbstractMockServerTest { @@ -130,10 +130,10 @@ public void createSpannerInstance() { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofNanos(1L)) - .setMaxRetryDelay(Duration.ofNanos(1L)) + .setInitialRetryDelayDuration(Duration.ofNanos(1L)) + .setMaxRetryDelayDuration(Duration.ofNanos(1L)) .setRetryDelayMultiplier(1.0) - .setTotalTimeout(Duration.ofMinutes(10L)) + .setTotalTimeoutDuration(Duration.ofMinutes(10L)) .build())); spanner = builder @@ -142,7 +142,7 @@ public void createSpannerInstance() { .setCredentials(NoCredentials.getInstance()) .setSessionPoolOption( SessionPoolOptions.newBuilder() - .setWaitForMinSessions(Duration.ofSeconds(5L)) + .setWaitForMinSessionsDuration(Duration.ofSeconds(5L)) .setFailOnSessionLeak() .build()) // Setting this to false so that Spanner Options does not register Metrics Tracer diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OpenTelemetrySpanTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OpenTelemetrySpanTest.java index a2aeb887733..f7f547ce357 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OpenTelemetrySpanTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OpenTelemetrySpanTest.java @@ -47,6 +47,7 @@ import io.opentelemetry.sdk.trace.data.SpanData; import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor; import java.lang.reflect.Modifier; +import java.time.Duration; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; @@ -60,7 +61,6 @@ import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @Category(TracerTest.class) @RunWith(JUnit4.class) @@ -237,7 +237,7 @@ public void setUp() throws Exception { .setSessionPoolOption( SessionPoolOptions.newBuilder() .setMinSessions(2) - .setWaitForMinSessions(Duration.ofSeconds(10)) + .setWaitForMinSessionsDuration(Duration.ofSeconds(10)) .build()); spanner = builder.build().getService(); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OperationTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OperationTest.java index 20fa72252f5..55211de1980 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OperationTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OperationTest.java @@ -31,12 +31,12 @@ import com.google.rpc.Code; import com.google.rpc.Status; import com.google.spanner.admin.database.v1.CreateDatabaseMetadata; +import java.time.Duration; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.Mock; -import org.threeten.bp.Duration; /** Unit tests for {@link Operation}. */ @RunWith(JUnit4.class) @@ -160,8 +160,8 @@ public void waitForCompletes() { op = op.waitFor( - RetryOption.totalTimeout(Duration.ofSeconds(3)), - RetryOption.initialRetryDelay(Duration.ZERO)); + RetryOption.totalTimeoutDuration(Duration.ofSeconds(3)), + RetryOption.initialRetryDelayDuration(Duration.ZERO)); assertThat(op.getName()).isEqualTo("op1"); assertThat(op.isDone()).isTrue(); @@ -181,8 +181,8 @@ public void waitForTimeout() { SpannerException.class, () -> op.waitFor( - RetryOption.totalTimeout(Duration.ofMillis(100L)), - RetryOption.initialRetryDelay(Duration.ZERO))); + RetryOption.totalTimeoutDuration(Duration.ofMillis(100L)), + RetryOption.initialRetryDelayDuration(Duration.ZERO))); assertEquals(ErrorCode.DEADLINE_EXCEEDED, e.getErrorCode()); } } diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/PartitionedDmlTransactionTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/PartitionedDmlTransactionTest.java index 93e0e3eb3d0..68bfcca6146 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/PartitionedDmlTransactionTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/PartitionedDmlTransactionTest.java @@ -47,6 +47,7 @@ import com.google.spanner.v1.Transaction; import com.google.spanner.v1.TransactionSelector; import io.grpc.Status.Code; +import java.time.Duration; import java.util.Collections; import java.util.Iterator; import java.util.concurrent.TimeUnit; @@ -59,7 +60,6 @@ import org.mockito.MockitoAnnotations; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import org.threeten.bp.Duration; @SuppressWarnings("unchecked") @RunWith(JUnit4.class) diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/RetryOnDifferentGrpcChannelMockServerTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/RetryOnDifferentGrpcChannelMockServerTest.java index b5e3e2e54cf..267c6077add 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/RetryOnDifferentGrpcChannelMockServerTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/RetryOnDifferentGrpcChannelMockServerTest.java @@ -42,6 +42,7 @@ import io.grpc.Status; import java.io.IOException; import java.net.InetSocketAddress; +import java.time.Duration; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -58,7 +59,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class RetryOnDifferentGrpcChannelMockServerTest extends AbstractMockServerTest { @@ -125,7 +125,9 @@ SpannerOptions.Builder createSpannerOptionsBuilder() { public void testReadWriteTransaction_retriesOnNewChannel() { SpannerOptions.Builder builder = createSpannerOptionsBuilder(); builder.setSessionPoolOption( - SessionPoolOptions.newBuilder().setWaitForMinSessions(Duration.ofSeconds(5L)).build()); + SessionPoolOptions.newBuilder() + .setWaitForMinSessionsDuration(Duration.ofSeconds(5L)) + .build()); mockSpanner.setBeginTransactionExecutionTime( SimulatedExecutionTime.ofStickyException(Status.DEADLINE_EXCEEDED.asRuntimeException())); AtomicInteger attempts = new AtomicInteger(); @@ -159,7 +161,9 @@ public void testReadWriteTransaction_retriesOnNewChannel() { public void testReadWriteTransaction_stopsRetrying() { SpannerOptions.Builder builder = createSpannerOptionsBuilder(); builder.setSessionPoolOption( - SessionPoolOptions.newBuilder().setWaitForMinSessions(Duration.ofSeconds(5L)).build()); + SessionPoolOptions.newBuilder() + .setWaitForMinSessionsDuration(Duration.ofSeconds(5L)) + .build()); mockSpanner.setBeginTransactionExecutionTime( SimulatedExecutionTime.ofStickyException(Status.DEADLINE_EXCEEDED.asRuntimeException())); @@ -200,7 +204,7 @@ public void testDenyListedChannelIsCleared() { SpannerOptions.Builder builder = createSpannerOptionsBuilder(); builder.setSessionPoolOption( SessionPoolOptions.newBuilder() - .setWaitForMinSessions(Duration.ofSeconds(5)) + .setWaitForMinSessionsDuration(Duration.ofSeconds(5)) .setPoolMaintainerClock(clock) .build()); mockSpanner.setBeginTransactionExecutionTime( @@ -328,7 +332,9 @@ public void testSingleUseQuery_stopsRetrying() { public void testReadWriteTransaction_withGrpcContextDeadline_doesNotRetry() { SpannerOptions.Builder builder = createSpannerOptionsBuilder(); builder.setSessionPoolOption( - SessionPoolOptions.newBuilder().setWaitForMinSessions(Duration.ofSeconds(5L)).build()); + SessionPoolOptions.newBuilder() + .setWaitForMinSessionsDuration(Duration.ofSeconds(5L)) + .build()); mockSpanner.setBeginTransactionExecutionTime( SimulatedExecutionTime.ofMinimumAndRandomTime(500, 500)); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SamplesMockServerTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SamplesMockServerTest.java index d8dcfc10e05..61c8d0573d7 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SamplesMockServerTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SamplesMockServerTest.java @@ -23,10 +23,10 @@ import com.google.api.gax.rpc.StatusCode; import com.google.cloud.NoCredentials; import com.google.cloud.spanner.MockSpannerServiceImpl.StatementResult; +import java.time.Duration; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; /** Tests for samples that use an in-mem mock server instead of running on real Cloud Spanner. */ @RunWith(JUnit4.class) @@ -52,13 +52,13 @@ public void testSampleRetrySettings() { .setRetryableCodes(StatusCode.Code.UNAVAILABLE) .setRetrySettings( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(500)) - .setMaxRetryDelay(Duration.ofSeconds(16)) + .setInitialRetryDelayDuration(Duration.ofMillis(500)) + .setMaxRetryDelayDuration(Duration.ofSeconds(16)) .setRetryDelayMultiplier(1.5) - .setInitialRpcTimeout(Duration.ofNanos(1L)) - .setMaxRpcTimeout(Duration.ofNanos(1L)) + .setInitialRpcTimeoutDuration(Duration.ofNanos(1L)) + .setMaxRpcTimeoutDuration(Duration.ofNanos(1L)) .setRpcTimeoutMultiplier(1.0) - .setTotalTimeout(Duration.ofNanos(1L)) + .setTotalTimeoutDuration(Duration.ofNanos(1L)) .build()); // Create a Spanner client using the custom retry and timeout settings. try (Spanner spanner = builder.build().getService()) { diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolMaintainerBenchmark.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolMaintainerBenchmark.java index 5f624cb6092..0370f5420e2 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolMaintainerBenchmark.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolMaintainerBenchmark.java @@ -27,6 +27,7 @@ import com.google.spanner.v1.BatchCreateSessionsRequest; import com.google.spanner.v1.BeginTransactionRequest; import com.google.spanner.v1.DeleteSessionRequest; +import java.time.Duration; import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -46,7 +47,6 @@ import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.annotations.Warmup; -import org.threeten.bp.Duration; /** * Benchmarks for the SessionPoolMaintainer. Run these benchmarks from the command line like this: @@ -111,7 +111,7 @@ public void setup() throws Exception { .setSessionPoolOption( SessionPoolOptions.newBuilder() // Set idle timeout and loop frequency to very low values. - .setRemoveInactiveSessionAfter(Duration.ofMillis(idleTimeout)) + .setRemoveInactiveSessionAfterDuration(Duration.ofMillis(idleTimeout)) .setLoopFrequency(idleTimeout / 10) .build()) .build(); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolMaintainerMockServerTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolMaintainerMockServerTest.java index c74806161f6..99a773eeb0f 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolMaintainerMockServerTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolMaintainerMockServerTest.java @@ -33,13 +33,13 @@ import com.google.spanner.v1.StructType.Field; import com.google.spanner.v1.Type; import com.google.spanner.v1.TypeCode; +import java.time.Duration; import java.util.concurrent.TimeUnit; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class SessionPoolMaintainerMockServerTest extends AbstractMockServerTest { @@ -80,7 +80,7 @@ public void createSpannerInstance() { .setSessionPoolOption( SessionPoolOptions.newBuilder() .setPoolMaintainerClock(clock) - .setWaitForMinSessions(Duration.ofSeconds(10L)) + .setWaitForMinSessionsDuration(Duration.ofSeconds(10L)) .setFailOnSessionLeak() .build()) .build() diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolOptionsTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolOptionsTest.java index 2e3e2c85da3..9e16b3fb1c8 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolOptionsTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolOptionsTest.java @@ -25,6 +25,7 @@ import static org.junit.Assume.assumeFalse; import com.google.cloud.spanner.SessionPoolOptions.InactiveTransactionRemovalOptions; +import java.time.Duration; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -34,7 +35,6 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; -import org.threeten.bp.Duration; /** Unit tests for {@link com.google.cloud.spanner.SessionPoolOptions} */ @RunWith(Parameterized.class) @@ -223,10 +223,12 @@ public void setNegativeIdleTimeThreshold() { @Test public void setAcquireSessionTimeout() { SessionPoolOptions sessionPoolOptions1 = - SessionPoolOptions.newBuilder().setAcquireSessionTimeout(Duration.ofSeconds(20)).build(); + SessionPoolOptions.newBuilder() + .setAcquireSessionTimeoutDuration(Duration.ofSeconds(20)) + .build(); SessionPoolOptions sessionPoolOptions2 = SessionPoolOptions.newBuilder() - .setAcquireSessionTimeout(Duration.ofMillis(Long.MAX_VALUE)) + .setAcquireSessionTimeoutDuration(Duration.ofMillis(Long.MAX_VALUE)) .build(); assertEquals(Duration.ofSeconds(20), sessionPoolOptions1.getAcquireSessionTimeout()); @@ -235,13 +237,13 @@ public void setAcquireSessionTimeout() { @Test(expected = IllegalArgumentException.class) public void setAcquireSessionTimeout_valueLessThanLowerBound() { - SessionPoolOptions.newBuilder().setAcquireSessionTimeout(Duration.ofMillis(0)).build(); + SessionPoolOptions.newBuilder().setAcquireSessionTimeoutDuration(Duration.ofMillis(0)).build(); } @Test(expected = IllegalArgumentException.class) public void setAcquireSessionTimeout_valueMoreThanUpperBound() { SessionPoolOptions.newBuilder() - .setAcquireSessionTimeout(Duration.ofSeconds(Long.MAX_VALUE)) + .setAcquireSessionTimeoutDuration(Duration.ofSeconds(Long.MAX_VALUE)) .build(); } @@ -418,7 +420,7 @@ public void testToBuilder() { .build()); assertToBuilderRoundtrip( SessionPoolOptions.newBuilder() - .setRemoveInactiveSessionAfter( + .setRemoveInactiveSessionAfterDuration( Duration.ofMillis(ThreadLocalRandom.current().nextLong(10000))) .build()); assertToBuilderRoundtrip( @@ -438,11 +440,12 @@ public void testToBuilder() { .build()); assertToBuilderRoundtrip( SessionPoolOptions.newBuilder() - .setWaitForMinSessions(Duration.ofMillis(ThreadLocalRandom.current().nextLong(10000))) + .setWaitForMinSessionsDuration( + Duration.ofMillis(ThreadLocalRandom.current().nextLong(10000))) .build()); assertToBuilderRoundtrip( SessionPoolOptions.newBuilder() - .setAcquireSessionTimeout( + .setAcquireSessionTimeoutDuration( Duration.ofMillis(ThreadLocalRandom.current().nextLong(1, 10000))) .build()); assertToBuilderRoundtrip( diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolTest.java index 00339fd2946..0389410064a 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolTest.java @@ -105,6 +105,9 @@ import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader; import java.io.PrintWriter; import java.io.StringWriter; +import java.time.Duration; +import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -133,9 +136,6 @@ import org.junit.runners.Parameterized.Parameters; import org.mockito.Mock; import org.mockito.Mockito; -import org.threeten.bp.Duration; -import org.threeten.bp.Instant; -import org.threeten.bp.temporal.ChronoUnit; /** Tests for SessionPool that mock out the underlying stub. */ @RunWith(Parameterized.class) @@ -314,7 +314,7 @@ public void poolLifo() { options .toBuilder() .setMinSessions(2) - .setWaitForMinSessions(Duration.ofSeconds(10L)) + .setWaitForMinSessionsDuration(Duration.ofSeconds(10L)) .build(); pool = createPool(); pool.maybeWaitOnMinSessions(); @@ -350,7 +350,7 @@ public void poolFifo() throws Exception { options .toBuilder() .setMinSessions(2) - .setWaitForMinSessions(Duration.ofSeconds(10L)) + .setWaitForMinSessionsDuration(Duration.ofSeconds(10L)) .build(); pool = createPool(); pool.maybeWaitOnMinSessions(); @@ -398,7 +398,7 @@ public void poolAllPositions() throws Exception { .toBuilder() .setMinSessions(numSessions) .setMaxSessions(numSessions) - .setWaitForMinSessions(Duration.ofSeconds(10L)) + .setWaitForMinSessionsDuration(Duration.ofSeconds(10L)) .build(); pool = createPool(); pool.maybeWaitOnMinSessions(); @@ -2212,7 +2212,7 @@ public void testWaitOnMinSessionsWhenSessionsAreCreatedBeforeTimeout() { SessionPoolOptions.newBuilder() .setMinSessions(minSessions) .setMaxSessions(minSessions + 1) - .setWaitForMinSessions(Duration.ofSeconds(5)) + .setWaitForMinSessionsDuration(Duration.ofSeconds(5)) .build(); doAnswer( invocation -> @@ -2241,7 +2241,7 @@ public void testWaitOnMinSessionsThrowsExceptionWhenTimeoutIsReached() { SessionPoolOptions.newBuilder() .setMinSessions(minSessions + 1) .setMaxSessions(minSessions + 1) - .setWaitForMinSessions(Duration.ofMillis(100)) + .setWaitForMinSessionsDuration(Duration.ofMillis(100)) .build(); pool = createPool(new FakeClock(), new FakeMetricRegistry(), SPANNER_DEFAULT_LABEL_VALUES); pool.maybeWaitOnMinSessions(); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpanExceptionTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpanExceptionTest.java index 2f16cd7c922..d09e65dfc0b 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpanExceptionTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpanExceptionTest.java @@ -22,6 +22,7 @@ import com.google.cloud.NoCredentials; import com.google.cloud.spanner.connection.AbstractMockServerTest; import io.grpc.ManagedChannelBuilder; +import java.time.Duration; import java.util.ArrayList; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; @@ -31,7 +32,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class SpanExceptionTest extends AbstractMockServerTest { @@ -47,7 +47,7 @@ public void testReadOnlyTransaction() throws InterruptedException, ExecutionExce .setSessionPoolOption( SessionPoolOptions.newBuilder() .setMaxSessions(10) - .setAcquireSessionTimeout(Duration.ofMillis(10)) + .setAcquireSessionTimeoutDuration(Duration.ofMillis(10)) // .setAcquireSessionTimeout(null) .build()) .build() diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpanTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpanTest.java index ffe9e584de3..b87b7ba9752 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpanTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpanTest.java @@ -45,6 +45,7 @@ import io.opentelemetry.sdk.trace.SdkTracerProvider; import io.opentelemetry.sdk.trace.export.SimpleSpanProcessor; import java.lang.reflect.Modifier; +import java.time.Duration; import java.util.List; import java.util.Map; import java.util.concurrent.ScheduledThreadPoolExecutor; @@ -58,7 +59,6 @@ import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @Category(TracerTest.class) @RunWith(JUnit4.class) @@ -202,7 +202,7 @@ public void setUp() throws Exception { .setSessionPoolOption( SessionPoolOptions.newBuilder() .setMinSessions(2) - .setWaitForMinSessions(Duration.ofSeconds(10)) + .setWaitForMinSessionsDuration(Duration.ofSeconds(10)) .build()); spanner = builder.build().getService(); @@ -211,21 +211,21 @@ public void setUp() throws Exception { final RetrySettings retrySettings = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(1L)) - .setMaxRetryDelay(Duration.ofMillis(1L)) - .setInitialRpcTimeout(Duration.ofMillis(75L)) - .setMaxRpcTimeout(Duration.ofMillis(75L)) + .setInitialRetryDelayDuration(Duration.ofMillis(1L)) + .setMaxRetryDelayDuration(Duration.ofMillis(1L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(75L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(75L)) .setMaxAttempts(3) - .setTotalTimeout(Duration.ofMillis(200L)) + .setTotalTimeoutDuration(Duration.ofMillis(200L)) .build(); RetrySettings commitRetrySettings = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(1L)) - .setMaxRetryDelay(Duration.ofMillis(1L)) - .setInitialRpcTimeout(Duration.ofMillis(5000L)) - .setMaxRpcTimeout(Duration.ofMillis(10000L)) + .setInitialRetryDelayDuration(Duration.ofMillis(1L)) + .setMaxRetryDelayDuration(Duration.ofMillis(1L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(5000L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(10000L)) .setMaxAttempts(1) - .setTotalTimeout(Duration.ofMillis(20000L)) + .setTotalTimeoutDuration(Duration.ofMillis(20000L)) .build(); builder .getSpannerStubSettingsBuilder() diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerGaxRetryTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerGaxRetryTest.java index 90d76c6a2bb..8ce858e77d7 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerGaxRetryTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerGaxRetryTest.java @@ -41,6 +41,7 @@ import io.grpc.inprocess.InProcessServerBuilder; import io.grpc.protobuf.ProtoUtils; import java.io.IOException; +import java.time.Duration; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -51,7 +52,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class SpannerGaxRetryTest { @@ -151,7 +151,10 @@ public void setUp() throws Exception { // wait time is for multiplexed sessions if (sessionPoolOptions.getUseMultiplexedSession()) { sessionPoolOptions = - sessionPoolOptions.toBuilder().setWaitForMinSessions(Duration.ofSeconds(5)).build(); + sessionPoolOptions + .toBuilder() + .setWaitForMinSessionsDuration(Duration.ofSeconds(5)) + .build(); } builder.setSessionPoolOption(sessionPoolOptions); // Create one client with default timeout values and one with short timeout values specifically @@ -161,21 +164,21 @@ public void setUp() throws Exception { final RetrySettings retrySettings = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(1L)) - .setMaxRetryDelay(Duration.ofMillis(1L)) - .setInitialRpcTimeout(Duration.ofMillis(175L)) - .setMaxRpcTimeout(Duration.ofMillis(175L)) + .setInitialRetryDelayDuration(Duration.ofMillis(1L)) + .setMaxRetryDelayDuration(Duration.ofMillis(1L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(175L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(175L)) .setMaxAttempts(3) - .setTotalTimeout(Duration.ofMillis(200L)) + .setTotalTimeoutDuration(Duration.ofMillis(200L)) .build(); RetrySettings commitRetrySettings = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(1L)) - .setMaxRetryDelay(Duration.ofMillis(1L)) - .setInitialRpcTimeout(Duration.ofMillis(5000L)) - .setMaxRpcTimeout(Duration.ofMillis(10000L)) + .setInitialRetryDelayDuration(Duration.ofMillis(1L)) + .setMaxRetryDelayDuration(Duration.ofMillis(1L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(5000L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(10000L)) .setMaxAttempts(1) - .setTotalTimeout(Duration.ofMillis(20000L)) + .setTotalTimeoutDuration(Duration.ofMillis(20000L)) .build(); builder .getSpannerStubSettingsBuilder() diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java index 7b891fdb7a9..cdab8e1df8b 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java @@ -66,6 +66,7 @@ import io.opentelemetry.sdk.OpenTelemetrySdk; import io.opentelemetry.sdk.metrics.SdkMeterProvider; import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader; +import java.time.Duration; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; @@ -82,7 +83,6 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.Mockito; -import org.threeten.bp.Duration; /** Unit tests for {@link com.google.cloud.spanner.SpannerOptions}. */ @RunWith(JUnit4.class) @@ -151,40 +151,40 @@ public void builder() { public void testSpannerDefaultRetrySettings() { RetrySettings witRetryPolicy1 = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(250L)) + .setInitialRetryDelayDuration(Duration.ofMillis(250L)) .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(32000L)) - .setInitialRpcTimeout(Duration.ofMillis(3600000L)) + .setMaxRetryDelayDuration(Duration.ofMillis(32000L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(3600000L)) .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(3600000L)) - .setTotalTimeout(Duration.ofMillis(3600000L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(3600000L)) + .setTotalTimeoutDuration(Duration.ofMillis(3600000L)) .build(); RetrySettings witRetryPolicy2 = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(250L)) + .setInitialRetryDelayDuration(Duration.ofMillis(250L)) .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(32000L)) - .setInitialRpcTimeout(Duration.ofMillis(60000L)) + .setMaxRetryDelayDuration(Duration.ofMillis(32000L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(60000L)) .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(60000L)) - .setTotalTimeout(Duration.ofMillis(60000L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(60000L)) + .setTotalTimeoutDuration(Duration.ofMillis(60000L)) .build(); RetrySettings witRetryPolicy3 = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(250L)) + .setInitialRetryDelayDuration(Duration.ofMillis(250L)) .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(32000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) + .setMaxRetryDelayDuration(Duration.ofMillis(32000L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(30000L)) .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(30000L)) + .setTotalTimeoutDuration(Duration.ofMillis(30000L)) .build(); RetrySettings noRetry1 = RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(3600000L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(3600000L)) .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(3600000L)) - .setTotalTimeout(Duration.ofMillis(3600000L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(3600000L)) + .setTotalTimeoutDuration(Duration.ofMillis(3600000L)) .build(); SpannerOptions options = SpannerOptions.newBuilder().setProjectId("test-project").build(); SpannerStubSettings stubSettings = options.getSpannerStubSettings(); @@ -226,13 +226,13 @@ public void testSpannerDefaultRetrySettings() { public void testSpannerCustomRetrySettings() { RetrySettings retrySettings = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofSeconds(9999L)) + .setInitialRetryDelayDuration(Duration.ofSeconds(9999L)) .setRetryDelayMultiplier(9999.99D) - .setMaxRetryDelay(Duration.ofSeconds(9999L)) - .setInitialRpcTimeout(Duration.ofSeconds(9999L)) + .setMaxRetryDelayDuration(Duration.ofSeconds(9999L)) + .setInitialRpcTimeoutDuration(Duration.ofSeconds(9999L)) .setRpcTimeoutMultiplier(9999.99D) - .setMaxRpcTimeout(Duration.ofSeconds(9999L)) - .setTotalTimeout(Duration.ofSeconds(9999L)) + .setMaxRpcTimeoutDuration(Duration.ofSeconds(9999L)) + .setTotalTimeoutDuration(Duration.ofSeconds(9999L)) .build(); SpannerOptions.Builder builder = SpannerOptions.newBuilder().setProjectId("test-project"); SpannerStubSettings.Builder stubSettingsBuilder = builder.getSpannerStubSettingsBuilder(); @@ -294,30 +294,30 @@ public void testSpannerCustomRetrySettings() { public void testDatabaseAdminDefaultRetrySettings() { RetrySettings withRetryPolicy1 = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(1000L)) + .setInitialRetryDelayDuration(Duration.ofMillis(1000L)) .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(32000L)) - .setInitialRpcTimeout(Duration.ofMillis(3600000L)) + .setMaxRetryDelayDuration(Duration.ofMillis(32000L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(3600000L)) .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(3600000L)) - .setTotalTimeout(Duration.ofMillis(3600000L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(3600000L)) + .setTotalTimeoutDuration(Duration.ofMillis(3600000L)) .build(); RetrySettings withRetryPolicy2 = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(1000L)) + .setInitialRetryDelayDuration(Duration.ofMillis(1000L)) .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(32000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) + .setMaxRetryDelayDuration(Duration.ofMillis(32000L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(30000L)) .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(30000L)) + .setTotalTimeoutDuration(Duration.ofMillis(30000L)) .build(); RetrySettings noRetryPolicy2 = RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(30000L)) .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(30000L)) + .setTotalTimeoutDuration(Duration.ofMillis(30000L)) .build(); SpannerOptions options = SpannerOptions.newBuilder().setProjectId("test-project").build(); DatabaseAdminStubSettings stubSettings = options.getDatabaseAdminStubSettings(); @@ -347,13 +347,13 @@ public void testDatabaseAdminDefaultRetrySettings() { public void testDatabaseAdminCustomRetrySettings() { RetrySettings retrySettings = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofSeconds(9999L)) + .setInitialRetryDelayDuration(Duration.ofSeconds(9999L)) .setRetryDelayMultiplier(9999.99D) - .setMaxRetryDelay(Duration.ofSeconds(9999L)) - .setInitialRpcTimeout(Duration.ofSeconds(9999L)) + .setMaxRetryDelayDuration(Duration.ofSeconds(9999L)) + .setInitialRpcTimeoutDuration(Duration.ofSeconds(9999L)) .setRpcTimeoutMultiplier(9999.99D) - .setMaxRpcTimeout(Duration.ofSeconds(9999L)) - .setTotalTimeout(Duration.ofSeconds(9999L)) + .setMaxRpcTimeoutDuration(Duration.ofSeconds(9999L)) + .setTotalTimeoutDuration(Duration.ofSeconds(9999L)) .build(); SpannerOptions.Builder builder = SpannerOptions.newBuilder().setProjectId("test-project"); DatabaseAdminStubSettings.Builder stubSettingsBuilder = @@ -384,37 +384,37 @@ public void testDatabaseAdminCustomRetrySettings() { public void testInstanceAdminDefaultRetrySettings() { RetrySettings withRetryPolicy1 = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(1000L)) + .setInitialRetryDelayDuration(Duration.ofMillis(1000L)) .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(32000L)) - .setInitialRpcTimeout(Duration.ofMillis(3600000L)) + .setMaxRetryDelayDuration(Duration.ofMillis(32000L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(3600000L)) .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(3600000L)) - .setTotalTimeout(Duration.ofMillis(3600000L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(3600000L)) + .setTotalTimeoutDuration(Duration.ofMillis(3600000L)) .build(); RetrySettings withRetryPolicy2 = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(1000L)) + .setInitialRetryDelayDuration(Duration.ofMillis(1000L)) .setRetryDelayMultiplier(1.3) - .setMaxRetryDelay(Duration.ofMillis(32000L)) - .setInitialRpcTimeout(Duration.ofMillis(30000L)) + .setMaxRetryDelayDuration(Duration.ofMillis(32000L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(30000L)) .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(30000L)) + .setTotalTimeoutDuration(Duration.ofMillis(30000L)) .build(); RetrySettings noRetryPolicy1 = RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(3600000L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(3600000L)) .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(3600000L)) - .setTotalTimeout(Duration.ofMillis(3600000L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(3600000L)) + .setTotalTimeoutDuration(Duration.ofMillis(3600000L)) .build(); RetrySettings noRetryPolicy2 = RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(30000L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(30000L)) .setRpcTimeoutMultiplier(1.0) - .setMaxRpcTimeout(Duration.ofMillis(30000L)) - .setTotalTimeout(Duration.ofMillis(30000L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(30000L)) + .setTotalTimeoutDuration(Duration.ofMillis(30000L)) .build(); SpannerOptions options = SpannerOptions.newBuilder().setProjectId("test-project").build(); InstanceAdminStubSettings stubSettings = options.getInstanceAdminStubSettings(); @@ -451,13 +451,13 @@ public void testInstanceAdminDefaultRetrySettings() { public void testInstanceAdminCustomRetrySettings() { RetrySettings retrySettings = RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofSeconds(9999L)) + .setInitialRetryDelayDuration(Duration.ofSeconds(9999L)) .setRetryDelayMultiplier(9999.99D) - .setMaxRetryDelay(Duration.ofSeconds(9999L)) - .setInitialRpcTimeout(Duration.ofSeconds(9999L)) + .setMaxRetryDelayDuration(Duration.ofSeconds(9999L)) + .setInitialRpcTimeoutDuration(Duration.ofSeconds(9999L)) .setRpcTimeoutMultiplier(9999.99D) - .setMaxRpcTimeout(Duration.ofSeconds(9999L)) - .setTotalTimeout(Duration.ofSeconds(9999L)) + .setMaxRpcTimeoutDuration(Duration.ofSeconds(9999L)) + .setTotalTimeoutDuration(Duration.ofSeconds(9999L)) .build(); SpannerOptions.Builder builder = SpannerOptions.newBuilder().setProjectId("test-project"); InstanceAdminStubSettings.Builder stubSettingsBuilder = @@ -879,14 +879,14 @@ public void testSpannerCallContextTimeoutConfigurator_NullValues() { public void testSpannerCallContextTimeoutConfigurator_WithTimeouts() { SpannerCallContextTimeoutConfigurator configurator = SpannerCallContextTimeoutConfigurator.create(); - configurator.withBatchUpdateTimeout(Duration.ofSeconds(1L)); - configurator.withCommitTimeout(Duration.ofSeconds(2L)); - configurator.withExecuteQueryTimeout(Duration.ofSeconds(3L)); - configurator.withExecuteUpdateTimeout(Duration.ofSeconds(4L)); - configurator.withPartitionQueryTimeout(Duration.ofSeconds(5L)); - configurator.withPartitionReadTimeout(Duration.ofSeconds(6L)); - configurator.withReadTimeout(Duration.ofSeconds(7L)); - configurator.withRollbackTimeout(Duration.ofSeconds(8L)); + configurator.withBatchUpdateTimeoutDuration(Duration.ofSeconds(1L)); + configurator.withCommitTimeoutDuration(Duration.ofSeconds(2L)); + configurator.withExecuteQueryTimeoutDuration(Duration.ofSeconds(3L)); + configurator.withExecuteUpdateTimeoutDuration(Duration.ofSeconds(4L)); + configurator.withPartitionQueryTimeoutDuration(Duration.ofSeconds(5L)); + configurator.withPartitionReadTimeoutDuration(Duration.ofSeconds(6L)); + configurator.withReadTimeoutDuration(Duration.ofSeconds(7L)); + configurator.withRollbackTimeoutDuration(Duration.ofSeconds(8L)); ApiCallContext inputCallContext = GrpcCallContext.createDefault(); @@ -932,7 +932,7 @@ public void testSpannerCallContextTimeoutConfigurator_WithTimeouts() { inputCallContext, CommitRequest.getDefaultInstance(), SpannerGrpc.getCommitMethod()) - .getTimeout()) + .getTimeoutDuration()) .isEqualTo(Duration.ofSeconds(2L)); assertThat( configurator @@ -940,7 +940,7 @@ public void testSpannerCallContextTimeoutConfigurator_WithTimeouts() { inputCallContext, RollbackRequest.getDefaultInstance(), SpannerGrpc.getRollbackMethod()) - .getTimeout()) + .getTimeoutDuration()) .isEqualTo(Duration.ofSeconds(8L)); assertNull( @@ -954,7 +954,7 @@ public void testSpannerCallContextTimeoutConfigurator_WithTimeouts() { inputCallContext, ExecuteSqlRequest.getDefaultInstance(), SpannerGrpc.getExecuteStreamingSqlMethod()) - .getTimeout()) + .getTimeoutDuration()) .isEqualTo(Duration.ofSeconds(3L)); assertThat( configurator @@ -962,7 +962,7 @@ public void testSpannerCallContextTimeoutConfigurator_WithTimeouts() { inputCallContext, ExecuteBatchDmlRequest.getDefaultInstance(), SpannerGrpc.getExecuteBatchDmlMethod()) - .getTimeout()) + .getTimeoutDuration()) .isEqualTo(Duration.ofSeconds(1L)); assertNull( configurator.configure( @@ -973,7 +973,7 @@ public void testSpannerCallContextTimeoutConfigurator_WithTimeouts() { inputCallContext, ReadRequest.getDefaultInstance(), SpannerGrpc.getStreamingReadMethod()) - .getTimeout()) + .getTimeoutDuration()) .isEqualTo(Duration.ofSeconds(7L)); assertThat( @@ -982,7 +982,7 @@ public void testSpannerCallContextTimeoutConfigurator_WithTimeouts() { inputCallContext, PartitionQueryRequest.getDefaultInstance(), SpannerGrpc.getPartitionQueryMethod()) - .getTimeout()) + .getTimeoutDuration()) .isEqualTo(Duration.ofSeconds(5L)); assertThat( configurator @@ -990,7 +990,7 @@ public void testSpannerCallContextTimeoutConfigurator_WithTimeouts() { inputCallContext, PartitionReadRequest.getDefaultInstance(), SpannerGrpc.getPartitionReadMethod()) - .getTimeout()) + .getTimeoutDuration()) .isEqualTo(Duration.ofSeconds(6L)); } diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/StatementTimeoutTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/StatementTimeoutTest.java index 24817c84450..f55c55c6c93 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/StatementTimeoutTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/StatementTimeoutTest.java @@ -46,6 +46,7 @@ import com.google.spanner.v1.CommitRequest; import com.google.spanner.v1.ExecuteSqlRequest; import io.grpc.Status; +import java.time.Duration; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; @@ -58,7 +59,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @RunWith(JUnit4.class) public class StatementTimeoutTest extends AbstractMockServerTest { @@ -97,10 +97,10 @@ protected ITConnection createConnection() { .setPollingAlgorithm( OperationTimedPollAlgorithm.create( RetrySettings.newBuilder() - .setInitialRetryDelay(Duration.ofMillis(1L)) - .setMaxRetryDelay(Duration.ofMillis(1L)) + .setInitialRetryDelayDuration(Duration.ofMillis(1L)) + .setMaxRetryDelayDuration(Duration.ofMillis(1L)) .setRetryDelayMultiplier(1.0) - .setTotalTimeout(Duration.ofMinutes(10L)) + .setTotalTimeoutDuration(Duration.ofMinutes(10L)) .build()))) .build(); return createITConnection(options); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITBuiltInMetricsTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITBuiltInMetricsTest.java index 9ff7e06e813..258c1230709 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITBuiltInMetricsTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITBuiltInMetricsTest.java @@ -31,6 +31,8 @@ import com.google.monitoring.v3.TimeInterval; import com.google.protobuf.util.Timestamps; import java.io.IOException; +import java.time.Duration; +import java.time.Instant; import java.util.concurrent.TimeUnit; import org.junit.BeforeClass; import org.junit.ClassRule; @@ -39,8 +41,6 @@ import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; -import org.threeten.bp.Instant; @Category(ParallelIntegrationTest.class) @RunWith(JUnit4.class) diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITCommitTimestampTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITCommitTimestampTest.java index 5a3b5c14707..70c9cb3757a 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITCommitTimestampTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITCommitTimestampTest.java @@ -36,6 +36,8 @@ import com.google.cloud.spanner.connection.ConnectionOptions; import com.google.cloud.spanner.testing.RemoteSpannerHelper; import com.google.common.collect.ImmutableList; +import java.time.Duration; +import java.time.Instant; import java.util.Arrays; import java.util.Collections; import java.util.concurrent.ExecutionException; @@ -47,8 +49,6 @@ import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; -import org.threeten.bp.Instant; /** Integration test for commit timestamp of Cloud Spanner. */ @Category(ParallelIntegrationTest.class) diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPgJsonbTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPgJsonbTest.java index 7338c76f07e..634f7919658 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPgJsonbTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPgJsonbTest.java @@ -41,6 +41,7 @@ import com.google.common.collect.ImmutableList; import com.google.protobuf.ListValue; import com.google.protobuf.NullValue; +import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -57,7 +58,6 @@ import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @Category(ParallelIntegrationTest.class) @RunWith(JUnit4.class) diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPgNumericTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPgNumericTest.java index b5fc084a54c..bacb4718da0 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPgNumericTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPgNumericTest.java @@ -35,6 +35,7 @@ import com.google.cloud.spanner.testing.RemoteSpannerHelper; import com.google.common.collect.ImmutableList; import java.math.BigDecimal; +import java.time.Duration; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -47,7 +48,6 @@ import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @Category(ParallelIntegrationTest.class) @RunWith(JUnit4.class) diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPitrCreateDatabaseTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPitrCreateDatabaseTest.java index f9fa081e413..6056b857b18 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPitrCreateDatabaseTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPitrCreateDatabaseTest.java @@ -30,6 +30,7 @@ import com.google.cloud.spanner.ParallelIntegrationTest; import com.google.cloud.spanner.SpannerException; import com.google.cloud.spanner.testing.RemoteSpannerHelper; +import java.time.Duration; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -42,7 +43,6 @@ import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @Category(ParallelIntegrationTest.class) @RunWith(JUnit4.class) diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPitrUpdateDatabaseTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPitrUpdateDatabaseTest.java index fa756b2f277..c730a7fa36c 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPitrUpdateDatabaseTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPitrUpdateDatabaseTest.java @@ -35,6 +35,7 @@ import com.google.cloud.spanner.Statement; import com.google.cloud.spanner.testing.RemoteSpannerHelper; import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; +import java.time.Duration; import java.util.Collections; import java.util.List; import java.util.concurrent.TimeUnit; @@ -45,7 +46,6 @@ import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; -import org.threeten.bp.Duration; @Category(ParallelIntegrationTest.class) @RunWith(JUnit4.class) diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpcTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpcTest.java index b3ff3b8f1c2..a0f236b0fd7 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpcTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpcTest.java @@ -85,6 +85,7 @@ import io.opentelemetry.sdk.trace.samplers.Sampler; import java.io.IOException; import java.net.InetSocketAddress; +import java.time.Duration; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -96,7 +97,6 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; import org.junit.runners.Parameterized.Parameters; -import org.threeten.bp.Duration; @RunWith(Parameterized.class) public class GapicSpannerRpcTest { @@ -386,7 +386,7 @@ public ApiCallContext configure( // Sequence numbers are only assigned for DML statements, which means that // this is an update statement. if (sqlRequest.getSeqno() > 0L) { - return context.withTimeout(timeoutHolder.timeout); + return context.withTimeoutDuration(timeoutHolder.timeout); } } return null; From 1234447f25e62dbd2a002cfed5a2d6e905e0e617 Mon Sep 17 00:00:00 2001 From: Sri Harsha CH <57220027+harshachinta@users.noreply.github.com> Date: Fri, 6 Dec 2024 10:57:08 +0530 Subject: [PATCH 06/14] =?UTF-8?q?chore(spanner):=20support=20multiplexed?= =?UTF-8?q?=20session=20for=20rw=20transactions=20in=20ex=E2=80=A6=20(#347?= =?UTF-8?q?1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore(spanner): support multiplexed session for rw transactions in executor * chore(spanner): lint fix --- .../cloud/executor/spanner/CloudClientExecutor.java | 11 ++++++++--- .../cloud/spanner/SessionPoolOptionsHelper.java | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/google-cloud-spanner-executor/src/main/java/com/google/cloud/executor/spanner/CloudClientExecutor.java b/google-cloud-spanner-executor/src/main/java/com/google/cloud/executor/spanner/CloudClientExecutor.java index 69c0d4d3ea9..c82b6306eb8 100644 --- a/google-cloud-spanner-executor/src/main/java/com/google/cloud/executor/spanner/CloudClientExecutor.java +++ b/google-cloud-spanner-executor/src/main/java/com/google/cloud/executor/spanner/CloudClientExecutor.java @@ -829,10 +829,15 @@ private synchronized Spanner getClient(long timeoutSeconds, boolean useMultiplex com.google.cloud.spanner.SessionPoolOptions.Builder poolOptionsBuilder = com.google.cloud.spanner.SessionPoolOptions.newBuilder(); - SessionPoolOptionsHelper.setUseMultiplexedSession( - com.google.cloud.spanner.SessionPoolOptions.newBuilder(), useMultiplexedSession); + SessionPoolOptionsHelper.setUseMultiplexedSession(poolOptionsBuilder, useMultiplexedSession); SessionPoolOptionsHelper.setUseMultiplexedSessionBlindWrite( - com.google.cloud.spanner.SessionPoolOptions.newBuilder(), useMultiplexedSession); + poolOptionsBuilder, useMultiplexedSession); + SessionPoolOptionsHelper.setUseMultiplexedSessionForRW( + poolOptionsBuilder, useMultiplexedSession); + LOGGER.log( + Level.INFO, + String.format( + "Using multiplexed sessions for read-write transactions: %s", useMultiplexedSession)); com.google.cloud.spanner.SessionPoolOptions sessionPoolOptions = poolOptionsBuilder.build(); // Cloud Spanner Client does not support global retry settings, // Thus, we need to add retry settings to each individual stub. diff --git a/google-cloud-spanner-executor/src/main/java/com/google/cloud/spanner/SessionPoolOptionsHelper.java b/google-cloud-spanner-executor/src/main/java/com/google/cloud/spanner/SessionPoolOptionsHelper.java index dafaa4a1f31..8e085947711 100644 --- a/google-cloud-spanner-executor/src/main/java/com/google/cloud/spanner/SessionPoolOptionsHelper.java +++ b/google-cloud-spanner-executor/src/main/java/com/google/cloud/spanner/SessionPoolOptionsHelper.java @@ -38,4 +38,10 @@ public static SessionPoolOptions.Builder setUseMultiplexedSessionBlindWrite( return sessionPoolOptionsBuilder.setUseMultiplexedSessionBlindWrite( useMultiplexedSessionBlindWrite); } + + // TODO: Remove when multiplexed session for read write is released. + public static SessionPoolOptions.Builder setUseMultiplexedSessionForRW( + SessionPoolOptions.Builder sessionPoolOptionsBuilder, boolean useMultiplexedSessionForRW) { + return sessionPoolOptionsBuilder.setUseMultiplexedSessionForRW(useMultiplexedSessionForRW); + } } From 134be9b21103bee4920d34b1eb7154f92765c78b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Olav=20L=C3=B8ite?= Date: Sun, 8 Dec 2024 11:34:44 +0100 Subject: [PATCH 07/14] chore: remove unused code and fix some warnings (#3533) --- .../spanner/connection/ConnectionImpl.java | 38 ++++--------------- 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionImpl.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionImpl.java index 1b94702061c..d7a1052d1c1 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionImpl.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionImpl.java @@ -94,8 +94,8 @@ import io.opentelemetry.api.trace.Span; import io.opentelemetry.api.trace.Tracer; import java.io.File; -import java.io.FileInputStream; import java.io.InputStream; +import java.nio.file.Files; import java.time.Duration; import java.time.Instant; import java.util.ArrayList; @@ -109,7 +109,6 @@ import java.util.UUID; import java.util.concurrent.ExecutionException; import java.util.concurrent.RejectedExecutionException; -import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.stream.Collectors; @@ -130,9 +129,6 @@ class ConnectionImpl implements Connection { "This method may only be called while in autocommit mode"; private static final String NOT_ALLOWED_IN_AUTOCOMMIT = "This method may not be called while in autocommit mode"; - - private static final ParsedStatement BEGIN_STATEMENT = - AbstractStatementParser.getInstance(Dialect.GOOGLE_STANDARD_SQL).parse(Statement.of("BEGIN")); private static final ParsedStatement COMMIT_STATEMENT = AbstractStatementParser.getInstance(Dialect.GOOGLE_STANDARD_SQL) .parse(Statement.of("COMMIT")); @@ -145,9 +141,6 @@ class ConnectionImpl implements Connection { private static final ParsedStatement START_BATCH_DML_STATEMENT = AbstractStatementParser.getInstance(Dialect.GOOGLE_STANDARD_SQL) .parse(Statement.of("START BATCH DML")); - private static final ParsedStatement RUN_BATCH_STATEMENT = - AbstractStatementParser.getInstance(Dialect.GOOGLE_STANDARD_SQL) - .parse(Statement.of("RUN BATCH")); // These SAVEPOINT statements are used as sentinels to recognize the start/rollback/release of a // savepoint. @@ -185,17 +178,6 @@ private LeakedConnectionException() { private final ConnectionStatementExecutor connectionStatementExecutor = new ConnectionStatementExecutorImpl(this); - /** Simple thread factory that is used for fire-and-forget rollbacks. */ - static final class DaemonThreadFactory implements ThreadFactory { - @Override - public Thread newThread(Runnable r) { - Thread t = new Thread(r); - t.setName("connection-rollback-executor"); - t.setDaemon(true); - return t; - } - } - /** * Statements are executed using a separate thread in order to be able to cancel these. Statements * are automatically cancelled if the configured {@link ConnectionImpl#statementTimeout} is @@ -507,11 +489,6 @@ UnitOfWorkType getUnitOfWorkType() { return unitOfWorkType; } - /** Get the current batch mode of this connection. */ - BatchMode getBatchMode() { - return batchMode; - } - /** @return true if this connection is in a batch. */ boolean isInBatch() { return batchMode != BatchMode.NONE; @@ -900,7 +877,7 @@ public byte[] getProtoDescriptors() { String.format( "File %s is not a valid proto descriptors file", this.protoDescriptorsFilePath)); } - InputStream pdStream = new FileInputStream(protoDescriptorsFile); + InputStream pdStream = Files.newInputStream(protoDescriptorsFile.toPath()); this.protoDescriptors = ByteArray.copyFrom(pdStream).toByteArray(); } catch (Exception exception) { throw SpannerExceptionFactory.newSpannerException(exception); @@ -1420,7 +1397,7 @@ public ResultSet executeQuery(Statement query, QueryOption... options) { @Override public AsyncResultSet executeQueryAsync(Statement query, QueryOption... options) { - return parseAndExecuteQueryAsync(CallType.ASYNC, query, AnalyzeMode.NONE, options); + return parseAndExecuteQueryAsync(query, options); } @Override @@ -1620,8 +1597,7 @@ private ResultSet parseAndExecuteQuery( + parsedStatement.getSqlWithoutComments()); } - private AsyncResultSet parseAndExecuteQueryAsync( - CallType callType, Statement query, AnalyzeMode analyzeMode, QueryOption... options) { + private AsyncResultSet parseAndExecuteQueryAsync(Statement query, QueryOption... options) { Preconditions.checkNotNull(query); ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG); ParsedStatement parsedStatement = getStatementParser().parse(query, buildQueryOptions()); @@ -1636,7 +1612,8 @@ private AsyncResultSet parseAndExecuteQueryAsync( spanner.getAsyncExecutorProvider(), options); case QUERY: - return internalExecuteQueryAsync(callType, parsedStatement, analyzeMode, options); + return internalExecuteQueryAsync( + CallType.ASYNC, parsedStatement, AnalyzeMode.NONE, options); case UPDATE: if (parsedStatement.hasReturningClause()) { // Cannot execute DML statement with returning clause in read-only mode or in @@ -1649,7 +1626,8 @@ private AsyncResultSet parseAndExecuteQueryAsync( "DML statement with returning clause cannot be executed in read-only mode: " + parsedStatement.getSqlWithoutComments()); } - return internalExecuteQueryAsync(callType, parsedStatement, analyzeMode, options); + return internalExecuteQueryAsync( + CallType.ASYNC, parsedStatement, AnalyzeMode.NONE, options); } case DDL: case UNKNOWN: From 4501a3ea69a9346e8b95edf6f94ff839b509ec73 Mon Sep 17 00:00:00 2001 From: Pratick Chokhani Date: Mon, 9 Dec 2024 21:11:11 +0530 Subject: [PATCH 08/14] feat(spanner): support multiplexed session for Partitioned operations (#3231) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(spanner): support multiplexed session for Partitioned read or query. * chore(spanner): lint fixes * feat(spanner): support multiplexed session for Partitioned DML operations. * lint(spanner): javadoc fixes. * feat(spanner): Updated unit tests of Partitioned operations for Multiplexed Session. * feat(spanner): Updated unit tests of Partitioned operations for Multiplexed Session. * lint(spanner): Apply suggestions from code review Co-authored-by: Knut Olav Løite * lint(spanner): Apply suggestions from code review Co-authored-by: Knut Olav Løite * feat(spanner): Modified BatchClientImpl to store multiplexed session and create fresh session after expiration date. * feat(spanner): Removed env variable for Partitioned Ops ensuring that Multiplexed Session for Partitioned Ops is not available to customers. * lint(spanner): Removed unused variables. --------- Co-authored-by: Knut Olav Løite --- .github/workflows/ci.yaml | 2 + ...tegration-multiplexed-sessions-enabled.cfg | 5 ++ .../spanner/SessionPoolOptionsHelper.java | 8 +++ ...tractMultiplexedSessionDatabaseClient.java | 6 -- .../google/cloud/spanner/BatchClientImpl.java | 57 +++++++++++++++++- .../cloud/spanner/DatabaseClientImpl.java | 13 ++++ .../DelayedMultiplexedSessionTransaction.java | 13 ++++ .../MultiplexedSessionDatabaseClient.java | 7 +++ .../google/cloud/spanner/SessionClient.java | 45 ++++++-------- .../cloud/spanner/SessionPoolOptions.java | 59 ++++++++++++++++--- .../com/google/cloud/spanner/SpannerImpl.java | 27 ++++++++- .../cloud/spanner/BatchClientImplTest.java | 29 +++++++-- .../cloud/spanner/BatchTransactionIdTest.java | 3 + .../IntegrationTestWithClosedSessionsEnv.java | 1 + ...edSessionDatabaseClientMockServerTest.java | 1 + .../RetryOnInvalidatedSessionTest.java | 3 + 16 files changed, 230 insertions(+), 49 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7eca4c6d5f0..ee28d7f8a66 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -53,6 +53,7 @@ jobs: env: JOB_TYPE: test GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS: true + GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS_PARTITIONED_OPS: true units-java8: # Building using Java 17 and run the tests with Java 8 runtime name: "units (8)" @@ -92,6 +93,7 @@ jobs: env: JOB_TYPE: test GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS: true + GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS_PARTITIONED_OPS: true windows: runs-on: windows-latest steps: diff --git a/.kokoro/presubmit/integration-multiplexed-sessions-enabled.cfg b/.kokoro/presubmit/integration-multiplexed-sessions-enabled.cfg index 771405de422..49edd2e8df6 100644 --- a/.kokoro/presubmit/integration-multiplexed-sessions-enabled.cfg +++ b/.kokoro/presubmit/integration-multiplexed-sessions-enabled.cfg @@ -36,3 +36,8 @@ env_vars: { key: "GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS" value: "true" } + +env_vars: { + key: "GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS_PARTITIONED_OPS" + value: "true" +} diff --git a/google-cloud-spanner-executor/src/main/java/com/google/cloud/spanner/SessionPoolOptionsHelper.java b/google-cloud-spanner-executor/src/main/java/com/google/cloud/spanner/SessionPoolOptionsHelper.java index 8e085947711..f19cb8f4a2f 100644 --- a/google-cloud-spanner-executor/src/main/java/com/google/cloud/spanner/SessionPoolOptionsHelper.java +++ b/google-cloud-spanner-executor/src/main/java/com/google/cloud/spanner/SessionPoolOptionsHelper.java @@ -44,4 +44,12 @@ public static SessionPoolOptions.Builder setUseMultiplexedSessionForRW( SessionPoolOptions.Builder sessionPoolOptionsBuilder, boolean useMultiplexedSessionForRW) { return sessionPoolOptionsBuilder.setUseMultiplexedSessionForRW(useMultiplexedSessionForRW); } + + // TODO: Remove when multiplexed session for partitioned operations are released. + public static SessionPoolOptions.Builder setUseMultiplexedSessionForPartitionedOperations( + SessionPoolOptions.Builder sessionPoolOptionsBuilder, + boolean useMultiplexedSessionForPartitionedOps) { + return sessionPoolOptionsBuilder.setUseMultiplexedSessionPartitionedOps( + useMultiplexedSessionForPartitionedOps); + } } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/AbstractMultiplexedSessionDatabaseClient.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/AbstractMultiplexedSessionDatabaseClient.java index ebfb0e0a774..10ab997d88a 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/AbstractMultiplexedSessionDatabaseClient.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/AbstractMultiplexedSessionDatabaseClient.java @@ -19,7 +19,6 @@ import com.google.api.gax.rpc.ServerStream; import com.google.cloud.Timestamp; import com.google.cloud.spanner.Options.TransactionOption; -import com.google.cloud.spanner.Options.UpdateOption; import com.google.spanner.v1.BatchWriteResponse; /** @@ -51,9 +50,4 @@ public ServerStream batchWriteAtLeastOnce( throws SpannerException { throw new UnsupportedOperationException(); } - - @Override - public long executePartitionedUpdate(Statement stmt, UpdateOption... options) { - throw new UnsupportedOperationException(); - } } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/BatchClientImpl.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/BatchClientImpl.java index 3d886dd383b..a250fd5ba39 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/BatchClientImpl.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/BatchClientImpl.java @@ -30,16 +30,50 @@ import com.google.spanner.v1.PartitionReadRequest; import com.google.spanner.v1.PartitionResponse; import com.google.spanner.v1.TransactionSelector; +import java.time.Clock; +import java.time.Duration; +import java.time.Instant; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicReference; +import java.util.concurrent.locks.ReentrantLock; import javax.annotation.Nullable; +import javax.annotation.concurrent.GuardedBy; /** Default implementation for Batch Client interface. */ public class BatchClientImpl implements BatchClient { private final SessionClient sessionClient; - BatchClientImpl(SessionClient sessionClient) { + private final boolean isMultiplexedSessionEnabled; + + /** Lock to protect the multiplexed session. */ + private final ReentrantLock multiplexedSessionLock = new ReentrantLock(); + + /** The duration before we try to replace the multiplexed session. The default is 7 days. */ + private final Duration sessionExpirationDuration; + + /** The expiration date/time of the current multiplexed session. */ + @GuardedBy("multiplexedSessionLock") + private final AtomicReference expirationDate; + + @GuardedBy("multiplexedSessionLock") + private final AtomicReference multiplexedSessionReference; + + BatchClientImpl(SessionClient sessionClient, boolean isMultiplexedSessionEnabled) { this.sessionClient = checkNotNull(sessionClient); + this.isMultiplexedSessionEnabled = isMultiplexedSessionEnabled; + this.sessionExpirationDuration = + Duration.ofMillis( + sessionClient + .getSpanner() + .getOptions() + .getSessionPoolOptions() + .getMultiplexedSessionMaintenanceDuration() + .toMillis()); + // Initialize the expiration date to the start of time to avoid unnecessary null checks. + // This also ensured that a new session is created on first request. + this.expirationDate = new AtomicReference<>(Instant.MIN); + this.multiplexedSessionReference = new AtomicReference<>(); } @Override @@ -50,7 +84,12 @@ public String getDatabaseRole() { @Override public BatchReadOnlyTransaction batchReadOnlyTransaction(TimestampBound bound) { - SessionImpl session = sessionClient.createSession(); + SessionImpl session; + if (isMultiplexedSessionEnabled) { + session = getMultiplexedSession(); + } else { + session = sessionClient.createSession(); + } return new BatchReadOnlyTransactionImpl( MultiUseReadOnlyTransaction.newBuilder() .setSession(session) @@ -92,6 +131,20 @@ public BatchReadOnlyTransaction batchReadOnlyTransaction(BatchTransactionId batc batchTransactionId); } + private SessionImpl getMultiplexedSession() { + this.multiplexedSessionLock.lock(); + try { + if (Clock.systemUTC().instant().isAfter(this.expirationDate.get()) + || this.multiplexedSessionReference.get() == null) { + this.multiplexedSessionReference.set(this.sessionClient.createMultiplexedSession()); + this.expirationDate.set(Clock.systemUTC().instant().plus(this.sessionExpirationDuration)); + } + return this.multiplexedSessionReference.get(); + } finally { + this.multiplexedSessionLock.unlock(); + } + } + private static class BatchReadOnlyTransactionImpl extends MultiUseReadOnlyTransaction implements BatchReadOnlyTransaction { private final String sessionName; diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DatabaseClientImpl.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DatabaseClientImpl.java index d7f16f89524..f571354dacb 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DatabaseClientImpl.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DatabaseClientImpl.java @@ -36,6 +36,7 @@ class DatabaseClientImpl implements DatabaseClient { @VisibleForTesting final String clientId; @VisibleForTesting final SessionPool pool; @VisibleForTesting final MultiplexedSessionDatabaseClient multiplexedSessionDatabaseClient; + @VisibleForTesting final boolean useMultiplexedSessionPartitionedOps; @VisibleForTesting final boolean useMultiplexedSessionForRW; final boolean useMultiplexedSessionBlindWrite; @@ -47,6 +48,7 @@ class DatabaseClientImpl implements DatabaseClient { pool, /* useMultiplexedSessionBlindWrite = */ false, /* multiplexedSessionDatabaseClient = */ null, + /* useMultiplexedSessionPartitionedOps= */ false, tracer, /* useMultiplexedSessionForRW = */ false); } @@ -58,6 +60,7 @@ class DatabaseClientImpl implements DatabaseClient { pool, /* useMultiplexedSessionBlindWrite = */ false, /* multiplexedSessionDatabaseClient = */ null, + /* useMultiplexedSessionPartitionedOps= */ false, tracer, /* useMultiplexedSessionForRW = */ false); } @@ -67,12 +70,14 @@ class DatabaseClientImpl implements DatabaseClient { SessionPool pool, boolean useMultiplexedSessionBlindWrite, @Nullable MultiplexedSessionDatabaseClient multiplexedSessionDatabaseClient, + boolean useMultiplexedSessionPartitionedOps, TraceWrapper tracer, boolean useMultiplexedSessionForRW) { this.clientId = clientId; this.pool = pool; this.useMultiplexedSessionBlindWrite = useMultiplexedSessionBlindWrite; this.multiplexedSessionDatabaseClient = multiplexedSessionDatabaseClient; + this.useMultiplexedSessionPartitionedOps = useMultiplexedSessionPartitionedOps; this.tracer = tracer; this.useMultiplexedSessionForRW = useMultiplexedSessionForRW; } @@ -309,6 +314,14 @@ public AsyncTransactionManager transactionManagerAsync(TransactionOption... opti @Override public long executePartitionedUpdate(final Statement stmt, final UpdateOption... options) { + if (useMultiplexedSessionPartitionedOps) { + return getMultiplexedSession().executePartitionedUpdate(stmt, options); + } + return executePartitionedUpdateWithPooledSession(stmt, options); + } + + private long executePartitionedUpdateWithPooledSession( + final Statement stmt, final UpdateOption... options) { ISpan span = tracer.spanBuilder(PARTITION_DML_TRANSACTION); try (IScope s = tracer.withSpan(span)) { return runWithSessionRetry(session -> session.executePartitionedUpdate(stmt, options)); diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DelayedMultiplexedSessionTransaction.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DelayedMultiplexedSessionTransaction.java index ad3e6b0cf70..0193805cbeb 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DelayedMultiplexedSessionTransaction.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DelayedMultiplexedSessionTransaction.java @@ -24,6 +24,7 @@ import com.google.cloud.spanner.DelayedReadContext.DelayedReadOnlyTransaction; import com.google.cloud.spanner.MultiplexedSessionDatabaseClient.MultiplexedSessionTransaction; import com.google.cloud.spanner.Options.TransactionOption; +import com.google.cloud.spanner.Options.UpdateOption; import com.google.common.util.concurrent.MoreExecutors; import java.util.concurrent.ExecutionException; @@ -224,4 +225,16 @@ private SessionReference getSessionReference() { throw SpannerExceptionFactory.propagateInterrupt(interruptedException); } } + + /** + * Execute `stmt` within PARTITIONED_DML transaction using multiplexed session. This method is a + * blocking call as the interface expects to return the output of the `stmt`. + */ + @Override + public long executePartitionedUpdate(Statement stmt, UpdateOption... options) { + SessionReference sessionReference = getSessionReference(); + return new MultiplexedSessionTransaction( + client, span, sessionReference, NO_CHANNEL_HINT, /* singleUse = */ true) + .executePartitionedUpdate(stmt, options); + } } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClient.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClient.java index bd709adbd99..01f41a2dfdc 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClient.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClient.java @@ -24,6 +24,7 @@ import com.google.api.core.SettableApiFuture; import com.google.cloud.Timestamp; import com.google.cloud.spanner.Options.TransactionOption; +import com.google.cloud.spanner.Options.UpdateOption; import com.google.cloud.spanner.SessionClient.SessionConsumer; import com.google.cloud.spanner.SpannerException.ResourceNotFoundException; import com.google.common.annotations.VisibleForTesting; @@ -553,6 +554,12 @@ public AsyncTransactionManager transactionManagerAsync(TransactionOption... opti .transactionManagerAsync(options); } + @Override + public long executePartitionedUpdate(Statement stmt, UpdateOption... options) { + return createMultiplexedSessionTransaction(/* singleUse = */ true) + .executePartitionedUpdate(stmt, options); + } + /** * It is enough with one executor to maintain the multiplexed sessions in all the clients, as they * do not need to be updated often, and the maintenance task is light. The core pool size is set diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionClient.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionClient.java index 0eed13b018c..a3cbbf33826 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionClient.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionClient.java @@ -237,6 +237,19 @@ SessionImpl createSession() { * @param consumer The {@link SessionConsumer} to use for callbacks when sessions are available. */ void createMultiplexedSession(SessionConsumer consumer) { + try { + SessionImpl sessionImpl = createMultiplexedSession(); + consumer.onSessionReady(sessionImpl); + } catch (Throwable t) { + consumer.onSessionCreateFailure(t, 1); + } + } + + /** + * Creates a multiplexed session and returns it. A multiplexed session is not affiliated with any + * GRPC channel. In case of an error during the gRPC calls, an exception will be thrown. + */ + SessionImpl createMultiplexedSession() { ISpan span = spanner.getTracer().spanBuilder(SpannerImpl.CREATE_MULTIPLEXED_SESSION); try (IScope s = spanner.getTracer().withSpan(span)) { com.google.spanner.v1.Session session = @@ -253,10 +266,12 @@ void createMultiplexedSession(SessionConsumer consumer) { spanner, new SessionReference( session.getName(), session.getCreateTime(), session.getMultiplexed(), null)); - consumer.onSessionReady(sessionImpl); + span.addAnnotation( + String.format("Request for %d multiplexed session returned %d session", 1, 1)); + return sessionImpl; } catch (Throwable t) { span.setStatus(t); - consumer.onSessionCreateFailure(t, 1); + throw t; } finally { span.end(); } @@ -289,31 +304,7 @@ private CreateMultiplexedSessionsRunnable(SessionConsumer consumer) { @Override public void run() { - ISpan span = spanner.getTracer().spanBuilder(SpannerImpl.CREATE_MULTIPLEXED_SESSION); - try (IScope s = spanner.getTracer().withSpan(span)) { - com.google.spanner.v1.Session session = - spanner - .getRpc() - .createSession( - db.getName(), - spanner.getOptions().getDatabaseRole(), - spanner.getOptions().getSessionLabels(), - null, - true); - SessionImpl sessionImpl = - new SessionImpl( - spanner, - new SessionReference( - session.getName(), session.getCreateTime(), session.getMultiplexed(), null)); - span.addAnnotation( - String.format("Request for %d multiplexed session returned %d session", 1, 1)); - consumer.onSessionReady(sessionImpl); - } catch (Throwable t) { - span.setStatus(t); - consumer.onSessionCreateFailure(t, 1); - } finally { - span.end(); - } + createMultiplexedSession(consumer); } } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java index d4f3e598b11..a691f14817f 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java @@ -85,6 +85,9 @@ public class SessionPoolOptions { private final boolean useMultiplexedSessionForRW; + private final boolean useMultiplexedSessionForPartitionedOps; + + // TODO: Change to use java.time.Duration. private final Duration multiplexedSessionMaintenanceDuration; private SessionPoolOptions(Builder builder) { @@ -127,6 +130,14 @@ private SessionPoolOptions(Builder builder) { (useMultiplexedSessionForRWFromEnvVariable != null) ? useMultiplexedSessionForRWFromEnvVariable : builder.useMultiplexedSessionForRW; + // useMultiplexedSessionPartitionedOps priority => Environment var > private setter > client + // default + Boolean useMultiplexedSessionFromEnvVariablePartitionedOps = + getUseMultiplexedSessionFromEnvVariablePartitionedOps(); + this.useMultiplexedSessionForPartitionedOps = + (useMultiplexedSessionFromEnvVariablePartitionedOps != null) + ? useMultiplexedSessionFromEnvVariablePartitionedOps + : builder.useMultiplexedSessionPartitionedOps; this.multiplexedSessionMaintenanceDuration = builder.multiplexedSessionMaintenanceDuration; } @@ -349,17 +360,31 @@ public boolean getUseMultiplexedSessionForRW() { return getUseMultiplexedSession() && useMultiplexedSessionForRW; } + @VisibleForTesting + @InternalApi + public boolean getUseMultiplexedSessionPartitionedOps() { + return useMultiplexedSessionForPartitionedOps; + } + private static Boolean getUseMultiplexedSessionFromEnvVariable() { - String useMultiplexedSessionFromEnvVariable = - System.getenv("GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS"); - if (useMultiplexedSessionFromEnvVariable != null - && useMultiplexedSessionFromEnvVariable.length() > 0) { - if ("true".equalsIgnoreCase(useMultiplexedSessionFromEnvVariable) - || "false".equalsIgnoreCase(useMultiplexedSessionFromEnvVariable)) { - return Boolean.parseBoolean(useMultiplexedSessionFromEnvVariable); + return parseBooleanEnvVariable("GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS"); + } + + @VisibleForTesting + @InternalApi + protected static Boolean getUseMultiplexedSessionFromEnvVariablePartitionedOps() { + // Checks the value of env, GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS_PARTITIONED_OPS + // This returns null until Partitioned Operations is supported. + return null; + } + + private static Boolean parseBooleanEnvVariable(String variableName) { + String envVariable = System.getenv(variableName); + if (envVariable != null && envVariable.length() > 0) { + if ("true".equalsIgnoreCase(envVariable) || "false".equalsIgnoreCase(envVariable)) { + return Boolean.parseBoolean(envVariable); } else { - throw new IllegalArgumentException( - "GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS should be either true or false."); + throw new IllegalArgumentException(variableName + " should be either true or false."); } } return null; @@ -585,6 +610,12 @@ public static class Builder { // default. private boolean useMultiplexedSessionForRW = false; + // This field controls the default behavior of session management for Partitioned operations in + // Java client. + // Set useMultiplexedSessionPartitionedOps to true to make multiplexed session for Partitioned + // operations the default. + private boolean useMultiplexedSessionPartitionedOps = false; + private Duration multiplexedSessionMaintenanceDuration = Duration.ofDays(7); private Clock poolMaintainerClock = Clock.INSTANCE; @@ -628,6 +659,7 @@ private Builder(SessionPoolOptions options) { this.useMultiplexedSession = options.useMultiplexedSession; this.useMultiplexedSessionBlindWrite = options.useMultiplexedSessionBlindWrite; this.useMultiplexedSessionForRW = options.useMultiplexedSessionForRW; + this.useMultiplexedSessionPartitionedOps = options.useMultiplexedSessionForPartitionedOps; this.multiplexedSessionMaintenanceDuration = options.multiplexedSessionMaintenanceDuration; this.poolMaintainerClock = options.poolMaintainerClock; } @@ -847,6 +879,15 @@ Builder setUseMultiplexedSessionForRW(boolean useMultiplexedSessionForRW) { return this; } + /** + * Sets whether the client should use multiplexed session for Partitioned operations or not. + * This method is intentionally package-private and intended for internal use. + */ + Builder setUseMultiplexedSessionPartitionedOps(boolean useMultiplexedSessionPartitionedOps) { + this.useMultiplexedSessionPartitionedOps = useMultiplexedSessionPartitionedOps; + return this; + } + @VisibleForTesting Builder setMultiplexedSessionMaintenanceDuration( Duration multiplexedSessionMaintenanceDuration) { diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerImpl.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerImpl.java index 1348d586e3a..ed815c77088 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerImpl.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerImpl.java @@ -52,6 +52,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.locks.ReentrantLock; import java.util.logging.Level; import java.util.logging.Logger; import javax.annotation.Nullable; @@ -107,6 +108,11 @@ private static String nextDatabaseClientId(DatabaseId databaseId) { @GuardedBy("this") private final Map dbClients = new HashMap<>(); + @GuardedBy("dbBatchClientLock") + private final Map dbBatchClients = new HashMap<>(); + + private final ReentrantLock dbBatchClientLock = new ReentrantLock(); + private final CloseableExecutorProvider asyncExecutorProvider; @GuardedBy("this") @@ -308,6 +314,7 @@ public DatabaseClient getDatabaseClient(DatabaseId db) { pool, getOptions().getSessionPoolOptions().getUseMultiplexedSessionBlindWrite(), multiplexedSessionDatabaseClient, + getOptions().getSessionPoolOptions().getUseMultiplexedSessionPartitionedOps(), useMultiplexedSessionForRW); dbClients.put(db, dbClient); return dbClient; @@ -321,19 +328,37 @@ DatabaseClientImpl createDatabaseClient( SessionPool pool, boolean useMultiplexedSessionBlindWrite, @Nullable MultiplexedSessionDatabaseClient multiplexedSessionClient, + boolean useMultiplexedSessionPartitionedOps, boolean useMultiplexedSessionForRW) { return new DatabaseClientImpl( clientId, pool, useMultiplexedSessionBlindWrite, multiplexedSessionClient, + useMultiplexedSessionPartitionedOps, tracer, useMultiplexedSessionForRW); } @Override public BatchClient getBatchClient(DatabaseId db) { - return new BatchClientImpl(getSessionClient(db)); + if (getOptions().getSessionPoolOptions().getUseMultiplexedSessionPartitionedOps()) { + this.dbBatchClientLock.lock(); + try { + if (this.dbBatchClients.containsKey(db)) { + return this.dbBatchClients.get(db); + } + BatchClientImpl batchClient = + new BatchClientImpl( + getSessionClient(db), /*useMultiplexedSessionPartitionedOps=*/ true); + this.dbBatchClients.put(db, batchClient); + return batchClient; + } finally { + this.dbBatchClientLock.unlock(); + } + } + return new BatchClientImpl( + getSessionClient(db), /*useMultiplexedSessionPartitionedOps=*/ false); } @Override diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BatchClientImplTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BatchClientImplTest.java index 8d05df538a5..edafc7ddba9 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BatchClientImplTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BatchClientImplTest.java @@ -36,6 +36,7 @@ import com.google.spanner.v1.Session; import com.google.spanner.v1.Transaction; import io.opentelemetry.api.OpenTelemetry; +import java.time.Duration; import java.util.Collections; import java.util.Map; import org.junit.Before; @@ -56,6 +57,7 @@ public final class BatchClientImplTest { private static final String SESSION_NAME = DB_NAME + "/sessions/s1"; private static final ByteString TXN_ID = ByteString.copyFromUtf8("my-txn"); private static final String TIMESTAMP = "2017-11-15T10:54:20Z"; + private static boolean isMultiplexedSession = false; @Mock private SpannerRpc gapicRpc; @Mock private SpannerOptions spannerOptions; @@ -68,6 +70,11 @@ public final class BatchClientImplTest { public static void setupOpenTelemetry() { SpannerOptions.resetActiveTracingFramework(); SpannerOptions.enableOpenTelemetryTraces(); + Boolean useMultiplexedSessionFromEnvVariablePartitionedOps = + SessionPoolOptions.getUseMultiplexedSessionFromEnvVariablePartitionedOps(); + isMultiplexedSession = + useMultiplexedSessionFromEnvVariablePartitionedOps != null + && useMultiplexedSessionFromEnvVariablePartitionedOps; } @SuppressWarnings("unchecked") @@ -88,18 +95,32 @@ public void setUp() { when(spannerOptions.getTransportOptions()).thenReturn(transportOptions); SessionPoolOptions sessionPoolOptions = mock(SessionPoolOptions.class); when(sessionPoolOptions.getPoolMaintainerClock()).thenReturn(Clock.INSTANCE); + when(sessionPoolOptions.getUseMultiplexedSessionPartitionedOps()) + .thenReturn(isMultiplexedSession); + when(sessionPoolOptions.getMultiplexedSessionMaintenanceDuration()).thenReturn(Duration.ZERO); when(spannerOptions.getSessionPoolOptions()).thenReturn(sessionPoolOptions); @SuppressWarnings("resource") SpannerImpl spanner = new SpannerImpl(gapicRpc, spannerOptions); - client = new BatchClientImpl(spanner.getSessionClient(db)); + client = new BatchClientImpl(spanner.getSessionClient(db), isMultiplexedSession); } @SuppressWarnings("unchecked") @Test public void testBatchReadOnlyTxnWithBound() throws Exception { - Session sessionProto = Session.newBuilder().setName(SESSION_NAME).build(); - when(gapicRpc.createSession(eq(DB_NAME), anyString(), anyMap(), optionsCaptor.capture())) - .thenReturn(sessionProto); + Session sessionProto = + Session.newBuilder().setName(SESSION_NAME).setMultiplexed(isMultiplexedSession).build(); + if (isMultiplexedSession) { + when(gapicRpc.createSession( + eq(DB_NAME), + anyString(), + anyMap(), + optionsCaptor.capture(), + eq(isMultiplexedSession))) + .thenReturn(sessionProto); + } else { + when(gapicRpc.createSession(eq(DB_NAME), anyString(), anyMap(), optionsCaptor.capture())) + .thenReturn(sessionProto); + } com.google.protobuf.Timestamp timestamp = Timestamps.parse(TIMESTAMP); Transaction txnMetadata = Transaction.newBuilder().setId(TXN_ID).setReadTimestamp(timestamp).build(); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BatchTransactionIdTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BatchTransactionIdTest.java index cf431348ce5..81d4de41695 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BatchTransactionIdTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BatchTransactionIdTest.java @@ -50,5 +50,8 @@ public void serialization() { reserializeAndAssert( new BatchTransactionId( "testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MIN_VALUE)); + reserializeAndAssert( + new BatchTransactionId( + "testSession", ByteString.copyFromUtf8("testTxn"), Timestamp.MIN_VALUE)); } } diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestWithClosedSessionsEnv.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestWithClosedSessionsEnv.java index 6deca476fc3..72cfe0bfe44 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestWithClosedSessionsEnv.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestWithClosedSessionsEnv.java @@ -51,6 +51,7 @@ DatabaseClientImpl createDatabaseClient( SessionPool pool, boolean useMultiplexedSessionBlindWriteIgnore, MultiplexedSessionDatabaseClient ignore, + boolean useMultiplexedSessionPartitionedOpsIgnore, boolean useMultiplexedSessionForRWIgnore) { return new DatabaseClientWithClosedSessionImpl(clientId, pool, tracer); } diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClientMockServerTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClientMockServerTest.java index 9f3d0751471..3121b868b83 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClientMockServerTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClientMockServerTest.java @@ -95,6 +95,7 @@ public void createSpannerInstance() { .setUseMultiplexedSession(true) .setUseMultiplexedSessionBlindWrite(true) .setUseMultiplexedSessionForRW(true) + .setUseMultiplexedSessionPartitionedOps(true) // Set the maintainer to loop once every 1ms .setMultiplexedSessionMaintenanceLoopFrequency(Duration.ofMillis(1L)) // Set multiplexed sessions to be replaced once every 1ms diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/RetryOnInvalidatedSessionTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/RetryOnInvalidatedSessionTest.java index 42a62be33aa..3032a1cae40 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/RetryOnInvalidatedSessionTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/RetryOnInvalidatedSessionTest.java @@ -1273,6 +1273,9 @@ public void transactionManagerReadRowUsingIndexInvalidatedDuringTransaction() @Test public void partitionedDml() throws InterruptedException { + assumeFalse( + "Multiplexed session do not throw a SessionNotFound errors. ", + spanner.getOptions().getSessionPoolOptions().getUseMultiplexedSessionPartitionedOps()); assertThrowsSessionNotFoundIfShouldFail( () -> client.executePartitionedUpdate(UPDATE_STATEMENT)); } From 10912a669c084a79694c05fba7ecc8b834b6e81b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Olav=20L=C3=B8ite?= Date: Mon, 9 Dec 2024 17:09:16 +0100 Subject: [PATCH 09/14] test: enable more tests on the Emulator (#3535) Multiple tests were skipped on the Emulator, because the features that are covered by these tests were originally not supported on the Emulator. These features are now available on the Emulator, and the tests can be enabled. --- .../it/ITAsyncTransactionRetryTest.java | 6 - .../cloud/spanner/it/ITBatchReadTest.java | 62 +++---- .../google/cloud/spanner/it/ITDMLTest.java | 27 +-- .../cloud/spanner/it/ITDatabaseTest.java | 3 - .../cloud/spanner/it/ITDmlReturningTest.java | 28 ++- .../cloud/spanner/it/ITFloat32Test.java | 4 - .../it/ITForeignKeyDeleteCascadeTest.java | 174 ++++++++---------- .../cloud/spanner/it/ITJsonWriteReadTest.java | 26 +-- .../cloud/spanner/it/ITLargeReadTest.java | 41 ++--- .../cloud/spanner/it/ITPgJsonbTest.java | 38 ++-- .../cloud/spanner/it/ITPgNumericTest.java | 48 ++--- 11 files changed, 175 insertions(+), 282 deletions(-) diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/it/ITAsyncTransactionRetryTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/it/ITAsyncTransactionRetryTest.java index fa44ad6f5d9..744d7042df4 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/it/ITAsyncTransactionRetryTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/it/ITAsyncTransactionRetryTest.java @@ -17,10 +17,8 @@ package com.google.cloud.spanner.connection.it; import static com.google.cloud.spanner.SpannerApiFutures.get; -import static com.google.cloud.spanner.testing.EmulatorSpannerHelper.isUsingEmulator; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.fail; -import static org.junit.Assume.assumeFalse; import com.google.api.core.ApiFuture; import com.google.api.core.SettableApiFuture; @@ -580,7 +578,6 @@ public void testAbortWithResultSetFullyConsumed() { @Test public void testAbortWithConcurrentInsert() { - assumeFalse("concurrent transactions are not supported on the emulator", isUsingEmulator()); AbortInterceptor interceptor = new AbortInterceptor(0); try (ITConnection connection = createConnection(interceptor, new CountTransactionRetryListener())) { @@ -632,7 +629,6 @@ public void testAbortWithConcurrentInsert() { @Test public void testAbortWithConcurrentDelete() { - assumeFalse("concurrent transactions are not supported on the emulator", isUsingEmulator()); AbortInterceptor interceptor = new AbortInterceptor(0); // first insert two test records try (ITConnection connection = createConnection()) { @@ -686,7 +682,6 @@ public void testAbortWithConcurrentDelete() { @Test public void testAbortWithConcurrentUpdate() { - assumeFalse("concurrent transactions are not supported on the emulator", isUsingEmulator()); AbortInterceptor interceptor = new AbortInterceptor(0); // first insert two test records try (ITConnection connection = createConnection()) { @@ -746,7 +741,6 @@ public void testAbortWithConcurrentUpdate() { */ @Test public void testAbortWithUnseenConcurrentInsert() throws InterruptedException { - assumeFalse("concurrent transactions are not supported on the emulator", isUsingEmulator()); AbortInterceptor interceptor = new AbortInterceptor(0); try (ITConnection connection = createConnection(interceptor, new CountTransactionRetryListener())) { diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITBatchReadTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITBatchReadTest.java index 6598a3dca76..f028fbc2b15 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITBatchReadTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITBatchReadTest.java @@ -19,11 +19,9 @@ import static com.google.cloud.spanner.connection.ITAbstractSpannerTest.extractConnectionUrl; import static com.google.cloud.spanner.connection.ITAbstractSpannerTest.getKeyFile; import static com.google.cloud.spanner.connection.ITAbstractSpannerTest.hasValidKeyFile; -import static com.google.cloud.spanner.testing.EmulatorSpannerHelper.isUsingEmulator; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeFalse; import com.google.cloud.ByteArray; import com.google.cloud.Timestamp; @@ -96,10 +94,7 @@ public class ITBatchReadTest { public static List data() { List params = new ArrayList<>(); params.add(new DialectTestParameter(Dialect.GOOGLE_STANDARD_SQL)); - // PG dialect tests are not supported by the emulator - if (!isUsingEmulator()) { - params.add(new DialectTestParameter(Dialect.POSTGRESQL)); - } + params.add(new DialectTestParameter(Dialect.POSTGRESQL)); return params; } @@ -135,30 +130,28 @@ public static void setUpDatabase() throws Exception { List databaseClients = new ArrayList<>(); databaseClients.add(env.getTestHelper().getDatabaseClient(googleStandardDatabase)); - if (!isUsingEmulator()) { - postgreSQLDatabase = - env.getTestHelper().createTestDatabase(Dialect.POSTGRESQL, Collections.emptyList()); - env.getTestHelper() - .getClient() - .getDatabaseAdminClient() - .updateDatabaseDdl( - env.getTestHelper().getInstanceId().getInstance(), - postgreSQLDatabase.getId().getDatabase(), - ImmutableList.of( - "CREATE TABLE " - + TABLE_NAME - + " (" - + " Key bigint not null primary key," - + " Data bytea," - + " Fingerprint bigint," - + " Size bigint" - + ")", - "CREATE INDEX " + INDEX_NAME + " ON " + TABLE_NAME + "(Fingerprint)"), - null) - .get(); - postgreSQLBatchClient = env.getTestHelper().getBatchClient(postgreSQLDatabase); - databaseClients.add(env.getTestHelper().getDatabaseClient(postgreSQLDatabase)); - } + postgreSQLDatabase = + env.getTestHelper().createTestDatabase(Dialect.POSTGRESQL, Collections.emptyList()); + env.getTestHelper() + .getClient() + .getDatabaseAdminClient() + .updateDatabaseDdl( + env.getTestHelper().getInstanceId().getInstance(), + postgreSQLDatabase.getId().getDatabase(), + ImmutableList.of( + "CREATE TABLE " + + TABLE_NAME + + " (" + + " Key bigint not null primary key," + + " Data bytea," + + " Fingerprint bigint," + + " Size bigint" + + ")", + "CREATE INDEX " + INDEX_NAME + " ON " + TABLE_NAME + "(Fingerprint)"), + null) + .get(); + postgreSQLBatchClient = env.getTestHelper().getBatchClient(postgreSQLDatabase); + databaseClients.add(env.getTestHelper().getDatabaseClient(postgreSQLDatabase)); List rows = manyRows(); numRows = rows.size(); @@ -210,9 +203,6 @@ private Database getDatabase() { @Test public void read() { - assumeFalse( - "PostgreSQL does not support the PartitionRead RPC", dialect.dialect == Dialect.POSTGRESQL); - BitSet seenRows = new BitSet(numRows); TimestampBound bound = getRandomBound(); PartitionOptions partitionParams = getRandomPartitionOptions(); @@ -229,9 +219,6 @@ public void read() { @Test public void readUsingIndex() { - assumeFalse( - "PostgreSQL does not support the PartitionRead RPC", dialect.dialect == Dialect.POSTGRESQL); - TimestampBound bound = getRandomBound(); PartitionOptions partitionParams = getRandomPartitionOptions(); batchTxn = getBatchClient().batchReadOnlyTransaction(bound); @@ -258,8 +245,6 @@ public void readUsingIndex() { @Test public void dataBoostRead() { - assumeFalse("Emulator does not support data boost read", isUsingEmulator()); - BitSet seenRows = new BitSet(numRows); TimestampBound bound = getRandomBound(); PartitionOptions partitionParams = getRandomPartitionOptions(); @@ -312,7 +297,6 @@ private PartitionOptions getRandomPartitionOptions() { @Test public void dataBoostQuery() { - assumeFalse("Emulator does not support data boost query", isUsingEmulator()); BitSet seenRows = new BitSet(numRows); TimestampBound bound = getRandomBound(); PartitionOptions partitionParams = getRandomPartitionOptions(); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITDMLTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITDMLTest.java index 5ea30912103..ab3c8e24a8c 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITDMLTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITDMLTest.java @@ -16,14 +16,12 @@ package com.google.cloud.spanner.it; -import static com.google.cloud.spanner.testing.EmulatorSpannerHelper.isUsingEmulator; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import static org.junit.Assume.assumeFalse; import com.google.cloud.spanner.AbortedException; import com.google.cloud.spanner.Database; @@ -90,15 +88,13 @@ public static void setUpDatabase() { + " V INT64," + ") PRIMARY KEY (K)"); googleStandardSQLClient = env.getTestHelper().getDatabaseClient(googleStandardSQLDatabase); - if (!isUsingEmulator()) { - Database postgreSQLDatabase = - env.getTestHelper() - .createTestDatabase( - Dialect.POSTGRESQL, - Arrays.asList( - "CREATE TABLE T (" + " K VARCHAR PRIMARY KEY," + " V BIGINT" + ")")); - postgreSQLClient = env.getTestHelper().getDatabaseClient(postgreSQLDatabase); - } + Database postgreSQLDatabase = + env.getTestHelper() + .createTestDatabase( + Dialect.POSTGRESQL, + Arrays.asList( + "CREATE TABLE T (" + " K VARCHAR PRIMARY KEY," + " V BIGINT" + ")")); + postgreSQLClient = env.getTestHelper().getDatabaseClient(postgreSQLDatabase); } @AfterClass @@ -122,10 +118,7 @@ public void increaseTestIdAndDeleteTestData() { public static List data() { List params = new ArrayList<>(); params.add(new DialectTestParameter(Dialect.GOOGLE_STANDARD_SQL)); - // "PG dialect tests are not supported by the emulator" - if (!isUsingEmulator()) { - params.add(new DialectTestParameter(Dialect.POSTGRESQL)); - } + params.add(new DialectTestParameter(Dialect.POSTGRESQL)); return params; } @@ -389,10 +382,6 @@ public void standardDMLWithExecuteSQL() { @Test public void testUntypedNullValues() { - assumeFalse( - "Spanner PostgreSQL does not yet support untyped null values", - dialect.dialect == Dialect.POSTGRESQL); - DatabaseClient client = getClient(dialect.dialect); String sql; if (dialect.dialect == Dialect.POSTGRESQL) { diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITDatabaseTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITDatabaseTest.java index f9230b8836b..b9813d512fd 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITDatabaseTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITDatabaseTest.java @@ -20,7 +20,6 @@ import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -import static org.junit.Assume.assumeFalse; import com.google.api.client.util.ExponentialBackOff; import com.google.api.gax.longrunning.OperationFuture; @@ -182,8 +181,6 @@ public void instanceNotFound() { @Test public void testNumericPrimaryKey() { - assumeFalse("Emulator does not support numeric primary keys", isUsingEmulator()); - final String table = "NumericTable"; // Creates table with numeric primary key diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITDmlReturningTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITDmlReturningTest.java index 8cb465e4c84..f54365ba84d 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITDmlReturningTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITDmlReturningTest.java @@ -42,7 +42,6 @@ import com.google.cloud.spanner.TransactionRunner; import com.google.cloud.spanner.TransactionRunner.TransactionCallable; import com.google.cloud.spanner.connection.ConnectionOptions; -import com.google.cloud.spanner.testing.EmulatorSpannerHelper; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -75,8 +74,6 @@ public final class ITDmlReturningTest { @BeforeClass public static void setUpDatabase() { - assumeFalse( - "DML Returning is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator()); Database googleStandardSQLDatabase = env.getTestHelper() .createTestDatabase( @@ -85,18 +82,16 @@ public static void setUpDatabase() { + " V INT64," + ") PRIMARY KEY (K)"); googleStandardSQLClient = env.getTestHelper().getDatabaseClient(googleStandardSQLDatabase); - if (!isUsingEmulator()) { - Database postgreSQLDatabase = - env.getTestHelper() - .createTestDatabase( - Dialect.POSTGRESQL, - Collections.singletonList( - "CREATE TABLE T (" - + " \"K\" VARCHAR PRIMARY KEY," - + " \"V\" BIGINT" - + ")")); - postgreSQLClient = env.getTestHelper().getDatabaseClient(postgreSQLDatabase); - } + Database postgreSQLDatabase = + env.getTestHelper() + .createTestDatabase( + Dialect.POSTGRESQL, + Collections.singletonList( + "CREATE TABLE T (" + + " \"K\" VARCHAR PRIMARY KEY," + + " \"V\" BIGINT" + + ")")); + postgreSQLClient = env.getTestHelper().getDatabaseClient(postgreSQLDatabase); } @AfterClass @@ -222,6 +217,9 @@ private void executeUpdateAsync(long expectedCount, final String... stmts) { @Test public void dmlReturningWithExecutePartitionedUpdate() { + assumeFalse( + "The emulator does not dis-allow THEN RETURN statements for PDML", isUsingEmulator()); + SpannerException e = assertThrows( SpannerException.class, diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITFloat32Test.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITFloat32Test.java index 393c2db8755..1536912f686 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITFloat32Test.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITFloat32Test.java @@ -16,13 +16,11 @@ package com.google.cloud.spanner.it; -import static com.google.cloud.spanner.testing.EmulatorSpannerHelper.isUsingEmulator; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeFalse; import com.google.cloud.Timestamp; import com.google.cloud.spanner.Database; @@ -93,8 +91,6 @@ public static List data() { @BeforeClass public static void setUpDatabase() throws ExecutionException, InterruptedException, TimeoutException { - assumeFalse("Emulator does not support FLOAT32 yet", isUsingEmulator()); - Database googleStandardSQLDatabase = env.getTestHelper().createTestDatabase(GOOGLE_STANDARD_SQL_SCHEMA); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITForeignKeyDeleteCascadeTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITForeignKeyDeleteCascadeTest.java index fc7c860267a..448aab85114 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITForeignKeyDeleteCascadeTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITForeignKeyDeleteCascadeTest.java @@ -15,11 +15,11 @@ */ package com.google.cloud.spanner.it; +import static com.google.cloud.spanner.testing.EmulatorSpannerHelper.isUsingEmulator; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeFalse; import com.google.cloud.spanner.Database; import com.google.cloud.spanner.DatabaseAdminClient; @@ -33,7 +33,6 @@ import com.google.cloud.spanner.ResultSet; import com.google.cloud.spanner.SpannerException; import com.google.cloud.spanner.Statement; -import com.google.cloud.spanner.testing.EmulatorSpannerHelper; import com.google.common.collect.ImmutableList; import java.util.ArrayList; import java.util.Arrays; @@ -68,46 +67,44 @@ public static List data() { private static Database GOOGLE_STANDARD_SQL_DATABASE; private static Database POSTGRESQL_DATABASE; - private static List dbs = new ArrayList<>(); + private static final List dbs = new ArrayList<>(); @Parameterized.Parameter(0) public DialectTestParameter dialect; @BeforeClass public static void setUpDatabase() { - if (!EmulatorSpannerHelper.isUsingEmulator()) { - GOOGLE_STANDARD_SQL_DATABASE = - env.getTestHelper() - .createTestDatabase( - ImmutableList.of( - "CREATE TABLE Singer (\n" - + " singer_id INT64 NOT NULL,\n" - + " first_name STRING(1024),\n" - + ") PRIMARY KEY(singer_id)\n", - "CREATE TABLE Concert (\n" - + " venue_id INT64 NOT NULL,\n" - + " singer_id INT64 NOT NULL,\n" - + " CONSTRAINT Fk_Concert_Singer FOREIGN KEY (singer_id) REFERENCES Singer (singer_id) ON DELETE CASCADE" - + ") PRIMARY KEY(venue_id, singer_id)")); - POSTGRESQL_DATABASE = - env.getTestHelper() - .createTestDatabase( - Dialect.POSTGRESQL, - ImmutableList.of( - "CREATE TABLE Singer (\n" - + " singer_id BIGINT PRIMARY KEY,\n" - + " first_name VARCHAR\n" - + ")", - "CREATE TABLE Concert (\n" - + " venue_id BIGINT NOT NULL,\n" - + " singer_id BIGINT NOT NULL,\n" - + " PRIMARY KEY (venue_id, singer_id),\n" - + " CONSTRAINT Fk_Concert_Singer FOREIGN KEY (singer_id) REFERENCES Singer (singer_id) ON DELETE CASCADE\n" - + " )")); - - dbs.add(GOOGLE_STANDARD_SQL_DATABASE); - dbs.add(POSTGRESQL_DATABASE); - } + GOOGLE_STANDARD_SQL_DATABASE = + env.getTestHelper() + .createTestDatabase( + ImmutableList.of( + "CREATE TABLE Singer (\n" + + " singer_id INT64 NOT NULL,\n" + + " first_name STRING(1024),\n" + + ") PRIMARY KEY(singer_id)\n", + "CREATE TABLE Concert (\n" + + " venue_id INT64 NOT NULL,\n" + + " singer_id INT64 NOT NULL,\n" + + " CONSTRAINT Fk_Concert_Singer FOREIGN KEY (singer_id) REFERENCES Singer (singer_id) ON DELETE CASCADE\n" + + ") PRIMARY KEY(venue_id, singer_id)")); + POSTGRESQL_DATABASE = + env.getTestHelper() + .createTestDatabase( + Dialect.POSTGRESQL, + ImmutableList.of( + "CREATE TABLE Singer (\n" + + " singer_id BIGINT PRIMARY KEY,\n" + + " first_name VARCHAR\n" + + ")", + "CREATE TABLE Concert (\n" + + " venue_id BIGINT NOT NULL,\n" + + " singer_id BIGINT NOT NULL,\n" + + " PRIMARY KEY (venue_id, singer_id),\n" + + " CONSTRAINT \"Fk_Concert_Singer\" FOREIGN KEY (singer_id) REFERENCES Singer (singer_id) ON DELETE CASCADE\n" + + " )")); + + dbs.add(GOOGLE_STANDARD_SQL_DATABASE); + dbs.add(POSTGRESQL_DATABASE); } @AfterClass @@ -120,10 +117,6 @@ public static void tearDown() { @Test public void testForeignKeyDeleteCascadeConstraints_withCreateDDLStatements() { - assumeFalse( - "Emulator does not yet support foreign key delete cascade", - EmulatorSpannerHelper.isUsingEmulator()); - final DatabaseClient databaseClient = getCreatedDatabaseClient(); try (final ResultSet rs = databaseClient @@ -133,17 +126,17 @@ public void testForeignKeyDeleteCascadeConstraints_withCreateDDLStatements() { "SELECT DELETE_RULE\n" + "FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS\n" + "WHERE CONSTRAINT_NAME ='Fk_Concert_Singer'"))) { - while (rs.next()) { - assertEquals(rs.getString(DELETE_RULE_COLUMN_NAME), "CASCADE"); + assertTrue(rs.next()); + // TODO: Enable for the emulator when it returns the correct value for DELETE_RULE. + if (!isUsingEmulator()) { + assertEquals("CASCADE", rs.getString(0)); } + assertFalse(rs.next()); } } @Test public void testForeignKeyDeleteCascadeConstraints_withAlterDDLStatements() throws Exception { - assumeFalse( - "Emulator does not yet support foreign key delete cascade", - EmulatorSpannerHelper.isUsingEmulator()); // Creating new tables within this test to ensure we don't pollute tables used by other tests in // this class. List createStatements; @@ -160,7 +153,7 @@ public void testForeignKeyDeleteCascadeConstraints_withAlterDDLStatements() thro + " PRIMARY KEY (venue_id, singer_id)\n" + " )", "ALTER TABLE ConcertV2 " - + "ADD CONSTRAINT Fk_Concert_Singer_V2 FOREIGN KEY(singer_id) REFERENCES Singer(singer_id) " + + "ADD CONSTRAINT \"Fk_Concert_Singer_V2\" FOREIGN KEY(singer_id) REFERENCES Singer(singer_id) " + "ON DELETE CASCADE"); } else { createStatements = @@ -181,7 +174,7 @@ public void testForeignKeyDeleteCascadeConstraints_withAlterDDLStatements() thro env.getTestHelper().createTestDatabase(dialect.dialect, createStatements); dbs.add(createdDatabase); - final DatabaseClient databaseClient = getCreatedDatabaseClient(); + final DatabaseClient databaseClient = env.getTestHelper().getDatabaseClient(createdDatabase); try (final ResultSet rs = databaseClient @@ -190,10 +183,13 @@ public void testForeignKeyDeleteCascadeConstraints_withAlterDDLStatements() thro Statement.of( "SELECT DELETE_RULE\n" + "FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS\n" - + "WHERE CONSTRAINT_NAME ='Fk_Concert_Singer'"))) { - while (rs.next()) { - assertEquals(rs.getString(DELETE_RULE_COLUMN_NAME), "CASCADE"); + + "WHERE CONSTRAINT_NAME ='Fk_Concert_Singer_V2'"))) { + assertTrue(rs.next()); + // TODO: Enable when the emulator returns the correct value for this column. + if (!isUsingEmulator()) { + assertEquals("CASCADE", rs.getString(0)); } + assertFalse(rs.next()); } // remove the foreign key delete cascade constraint @@ -215,19 +211,15 @@ public void testForeignKeyDeleteCascadeConstraints_withAlterDDLStatements() thro Statement.of( "SELECT DELETE_RULE\n" + "FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS\n" - + "WHERE CONSTRAINT_NAME ='Fk_Concert_Singer_V2'"))) { - while (rs.next()) { - assertEquals(rs.getString(DELETE_RULE_COLUMN_NAME), "NO ACTION"); - } + + "WHERE LOWER(CONSTRAINT_NAME) ='fk_concert_singer_v2'"))) { + assertTrue(rs.next()); + assertEquals("NO ACTION", rs.getString(0)); + assertFalse(rs.next()); } } @Test public void testForeignKeyDeleteCascadeConstraints_verifyValidInsertions() { - assumeFalse( - "Emulator does not yet support foreign key delete cascade", - EmulatorSpannerHelper.isUsingEmulator()); - final DatabaseClient databaseClient = getCreatedDatabaseClient(); final String singerInsertStatement = "INSERT INTO Singer (singer_id, first_name) VALUES (" + generateQueryParameters(2) + ")"; @@ -289,10 +281,6 @@ public void testForeignKeyDeleteCascadeConstraints_verifyValidInsertions() { @Test public void testForeignKeyDeleteCascadeConstraints_verifyInvalidInsertions() { - assumeFalse( - "Emulator does not yet support foreign key delete cascade", - EmulatorSpannerHelper.isUsingEmulator()); - final DatabaseClient databaseClient = getCreatedDatabaseClient(); // unsuccessful inserts into referencing tables when foreign key is not inserted into referenced @@ -319,16 +307,12 @@ public void testForeignKeyDeleteCascadeConstraints_verifyInvalidInsertions() { transaction.executeUpdate(concertInsertStatementWithInvalidValues); return null; })); - assertEquals(ex.getErrorCode(), ErrorCode.FAILED_PRECONDITION); - assertTrue(ex.getMessage().contains("Cannot find referenced values")); + assertEquals(ErrorCode.FAILED_PRECONDITION, ex.getErrorCode()); + assertTrue(ex.getMessage(), ex.getMessage().contains("Cannot find referenced")); } @Test public void testForeignKeyDeleteCascadeConstraints_forDeletions() { - assumeFalse( - "Emulator does not yet support foreign key delete cascade", - EmulatorSpannerHelper.isUsingEmulator()); - final DatabaseClient databaseClient = getCreatedDatabaseClient(); final String singerInsertStatement = @@ -396,10 +380,6 @@ public void testForeignKeyDeleteCascadeConstraints_forDeletions() { @Test public void testForeignKeyDeleteCascadeConstraints_forMutations_onConflictDueToParentTable() { - assumeFalse( - "Emulator does not yet support foreign key delete cascade", - EmulatorSpannerHelper.isUsingEmulator()); - final DatabaseClient databaseClient = getCreatedDatabaseClient(); // inserting and deleting the referenced key within the same mutation are considered @@ -423,15 +403,11 @@ public void testForeignKeyDeleteCascadeConstraints_forMutations_onConflictDueToP Mutation.delete("Singer", Key.of(4L)))); return null; })); - assertEquals(ex.getErrorCode(), ErrorCode.FAILED_PRECONDITION); + assertEquals(ErrorCode.FAILED_PRECONDITION, ex.getErrorCode()); } @Test public void testForeignKeyDeleteCascadeConstraints_forMutations_onConflictsDueToChildTable() { - assumeFalse( - "Emulator does not yet support foreign key delete cascade", - EmulatorSpannerHelper.isUsingEmulator()); - final DatabaseClient databaseClient = getCreatedDatabaseClient(); // referencing a foreign key in child table and deleting the referenced key in parent table @@ -454,25 +430,24 @@ public void testForeignKeyDeleteCascadeConstraints_forMutations_onConflictsDueTo transaction.executeUpdate(singerInsertStatementWithValues); return null; }); - SpannerException ex = - assertThrows( - SpannerException.class, - () -> - databaseClient - .readWriteTransaction() - .run( - transaction -> { - transaction.buffer( - Arrays.asList( - Mutation.newInsertBuilder("Concert") - .set("first_name") - .to(5L) - .set("singer_id") - .to(5L) - .build(), - Mutation.delete("Singer", Key.of(5L)))); - return null; - })); + assertThrows( + SpannerException.class, + () -> + databaseClient + .readWriteTransaction() + .run( + transaction -> { + transaction.buffer( + Arrays.asList( + Mutation.newInsertBuilder("Concert") + .set("first_name") + .to(5L) + .set("singer_id") + .to(5L) + .build(), + Mutation.delete("Singer", Key.of(5L)))); + return null; + })); } private DatabaseAdminClient getDatabaseAdminClient() { @@ -481,16 +456,13 @@ private DatabaseAdminClient getDatabaseAdminClient() { private DatabaseClient getCreatedDatabaseClient() { if (dialect.dialect == Dialect.POSTGRESQL) { - return env.getTestHelper().getDatabaseClient(this.POSTGRESQL_DATABASE); + return env.getTestHelper().getDatabaseClient(POSTGRESQL_DATABASE); } - return env.getTestHelper().getDatabaseClient(this.GOOGLE_STANDARD_SQL_DATABASE); + return env.getTestHelper().getDatabaseClient(GOOGLE_STANDARD_SQL_DATABASE); } /** * Returns '@p1, @p2, ..., @pNumParams' for GoogleSQL and $1, $2, ..., $NumParams' for PostgreSQL - * - * @param numParams - * @return */ private String generateQueryParameters(final int numParams) { final List params; diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITJsonWriteReadTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITJsonWriteReadTest.java index c6f72349f0b..e355eaa07a3 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITJsonWriteReadTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITJsonWriteReadTest.java @@ -18,7 +18,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThrows; -import static org.junit.Assume.assumeFalse; import com.google.cloud.spanner.Database; import com.google.cloud.spanner.DatabaseClient; @@ -30,7 +29,6 @@ import com.google.cloud.spanner.SpannerException; import com.google.cloud.spanner.Statement; import com.google.cloud.spanner.Value; -import com.google.cloud.spanner.testing.EmulatorSpannerHelper; import com.google.cloud.spanner.testing.RemoteSpannerHelper; import com.google.common.io.Resources; import java.io.File; @@ -68,23 +66,19 @@ public class ITJsonWriteReadTest { @BeforeClass public static void beforeClass() { final RemoteSpannerHelper testHelper = env.getTestHelper(); - if (!EmulatorSpannerHelper.isUsingEmulator()) { - final Database database = - testHelper.createTestDatabase( - "CREATE TABLE " - + TABLE_NAME - + "(" - + "Id INT64 NOT NULL," - + "json JSON" - + ") PRIMARY KEY (Id)"); - databaseClient = testHelper.getDatabaseClient(database); - } + final Database database = + testHelper.createTestDatabase( + "CREATE TABLE " + + TABLE_NAME + + "(" + + "Id INT64 NOT NULL," + + "json JSON" + + ") PRIMARY KEY (Id)"); + databaseClient = testHelper.getDatabaseClient(database); } @Test public void testWriteValidJsonValues() throws IOException { - assumeFalse("Emulator does not yet support JSON", EmulatorSpannerHelper.isUsingEmulator()); - List resources = getJsonFilePaths(RESOURCES_DIR + File.separator + VALID_JSON_DIR); long id = 0L; @@ -116,8 +110,6 @@ public void testWriteValidJsonValues() throws IOException { @Test public void testWriteAndReadInvalidJsonValues() throws IOException { - assumeFalse("Emulator does not yet support JSON", EmulatorSpannerHelper.isUsingEmulator()); - List resources = getJsonFilePaths(RESOURCES_DIR + File.separator + INVALID_JSON_DIR); AtomicLong id = new AtomicLong(100); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITLargeReadTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITLargeReadTest.java index b60505c873a..83d505e2124 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITLargeReadTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITLargeReadTest.java @@ -16,7 +16,6 @@ package com.google.cloud.spanner.it; -import static com.google.cloud.spanner.testing.EmulatorSpannerHelper.isUsingEmulator; import static com.google.common.truth.Truth.assertThat; import com.google.cloud.ByteArray; @@ -31,6 +30,7 @@ import com.google.cloud.spanner.ResultSet; import com.google.cloud.spanner.Statement; import com.google.cloud.spanner.connection.ConnectionOptions; +import com.google.common.collect.ImmutableList; import com.google.common.hash.HashFunction; import com.google.common.hash.Hashing; import java.util.ArrayList; @@ -88,20 +88,18 @@ public static void setUpDatabase() { + " Size INT64," + ") PRIMARY KEY (Key)"); googleStandardSQLClient = env.getTestHelper().getDatabaseClient(googleStandardSQLDatabase); - if (!isUsingEmulator()) { - Database postgreSQLDatabase = - env.getTestHelper() - .createTestDatabase( - Dialect.POSTGRESQL, - Arrays.asList( - "CREATE TABLE TestTable (" - + " Key BIGINT PRIMARY KEY," - + " Data BYTEA," - + " Fingerprint BIGINT," - + " Size BIGINT" - + ")")); - postgreSQLClient = env.getTestHelper().getDatabaseClient(postgreSQLDatabase); - } + Database postgreSQLDatabase = + env.getTestHelper() + .createTestDatabase( + Dialect.POSTGRESQL, + ImmutableList.of( + "CREATE TABLE TestTable (" + + " Key BIGINT PRIMARY KEY," + + " Data BYTEA," + + " Fingerprint BIGINT," + + " Size BIGINT" + + ")")); + postgreSQLClient = env.getTestHelper().getDatabaseClient(postgreSQLDatabase); hasher = Hashing.goodFastHash(64); List mutations = new ArrayList<>(); @@ -127,17 +125,13 @@ public static void setUpDatabase() { i++; if (totalSize >= WRITE_BATCH_SIZE) { googleStandardSQLClient.write(mutations); - if (!isUsingEmulator()) { - postgreSQLClient.write(mutations); - } + postgreSQLClient.write(mutations); mutations.clear(); totalSize = 0; } } googleStandardSQLClient.write(mutations); - if (!isUsingEmulator()) { - postgreSQLClient.write(mutations); - } + postgreSQLClient.write(mutations); } @AfterClass @@ -149,10 +143,7 @@ public static void teardown() { public static List data() { List params = new ArrayList<>(); params.add(new DialectTestParameter(Dialect.GOOGLE_STANDARD_SQL)); - // "PG dialect tests are not supported by the emulator" - if (!isUsingEmulator()) { - params.add(new DialectTestParameter(Dialect.POSTGRESQL)); - } + params.add(new DialectTestParameter(Dialect.POSTGRESQL)); return params; } diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPgJsonbTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPgJsonbTest.java index 634f7919658..275fbe6545f 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPgJsonbTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPgJsonbTest.java @@ -16,11 +16,11 @@ package com.google.cloud.spanner.it; +import static com.google.cloud.spanner.testing.EmulatorSpannerHelper.isUsingEmulator; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeFalse; import com.google.cloud.spanner.Database; import com.google.cloud.spanner.DatabaseAdminClient; @@ -36,7 +36,6 @@ import com.google.cloud.spanner.SpannerExceptionFactory; import com.google.cloud.spanner.Statement; import com.google.cloud.spanner.Value; -import com.google.cloud.spanner.testing.EmulatorSpannerHelper; import com.google.cloud.spanner.testing.RemoteSpannerHelper; import com.google.common.collect.ImmutableList; import com.google.protobuf.ListValue; @@ -53,7 +52,6 @@ import org.junit.Before; import org.junit.BeforeClass; import org.junit.ClassRule; -import org.junit.Ignore; import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; @@ -77,8 +75,6 @@ public class ITPgJsonbTest { @BeforeClass public static void beforeClass() throws Exception { - assumeFalse( - "PgJsonb is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator()); testHelper = env.getTestHelper(); databaseAdminClient = testHelper.getClient().getDatabaseAdminClient(); databasesToDrop = new ArrayList<>(); @@ -97,7 +93,7 @@ public static void beforeClass() throws Exception { } @AfterClass - public static void afterClass() throws Exception { + public static void afterClass() { if (databasesToDrop != null) { for (DatabaseId id : databasesToDrop) { try { @@ -170,11 +166,19 @@ public void testPgJsonbInSecondaryIndex() { SpannerException spannerException = SpannerExceptionFactory.asSpannerException(executionException.getCause()); assertEquals(ErrorCode.FAILED_PRECONDITION, spannerException.getErrorCode()); - assertTrue( - spannerException.getMessage(), - spannerException - .getMessage() - .contains("Index idx_jsonb is defined on a column of unsupported type PG.JSONB.")); + if (isUsingEmulator()) { + assertTrue( + spannerException.getMessage(), + spannerException + .getMessage() + .contains("Cannot reference PG.JSONB col1 in the creation of index idx_jsonb.")); + } else { + assertTrue( + spannerException.getMessage(), + spannerException + .getMessage() + .contains("Index idx_jsonb is defined on a column of unsupported type PG.JSONB.")); + } } private static final String JSON_VALUE_1 = "{\"color\":\"red\",\"value\":\"#f00\"}"; @@ -189,8 +193,6 @@ public void testPgJsonbInSecondaryIndex() { @Test public void testLiteralPgJsonb() { - assumeFalse( - "PgJsonb is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator()); databaseClient .readWriteTransaction() .run( @@ -223,8 +225,6 @@ public void testLiteralPgJsonb() { @Test public void testPgJsonbParameter() { - assumeFalse( - "PgJsonb is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator()); databaseClient .readWriteTransaction() .run( @@ -275,12 +275,8 @@ private ListValue getJsonListValue(List jsonList) { .build(); } - @Ignore("Untyped jsonb parameters are not yet supported") @Test public void testPgJsonbUntypedParameter() { - assumeFalse( - "PgJsonb is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator()); - // Verify that we can use Jsonb as an untyped parameter. This is especially important for // PGAdapter and the JDBC driver, as these will often use untyped parameters. databaseClient @@ -362,8 +358,6 @@ public void testPgJsonbUntypedParameter() { @Test public void testMutationsWithPgJsonbAsString() { - assumeFalse( - "PgJsonb is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator()); databaseClient .readWriteTransaction() .run( @@ -418,8 +412,6 @@ public void testMutationsWithPgJsonbAsString() { @Test public void testMutationsWithPgJsonbAsValue() { - assumeFalse( - "PgJsonb is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator()); databaseClient .readWriteTransaction() .run( diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPgNumericTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPgNumericTest.java index bacb4718da0..76025b07175 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPgNumericTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITPgNumericTest.java @@ -18,7 +18,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeFalse; import com.google.cloud.spanner.Database; import com.google.cloud.spanner.DatabaseAdminClient; @@ -31,7 +30,6 @@ import com.google.cloud.spanner.ResultSet; import com.google.cloud.spanner.Statement; import com.google.cloud.spanner.Value; -import com.google.cloud.spanner.testing.EmulatorSpannerHelper; import com.google.cloud.spanner.testing.RemoteSpannerHelper; import com.google.common.collect.ImmutableList; import java.math.BigDecimal; @@ -67,8 +65,6 @@ public class ITPgNumericTest { @BeforeClass public static void beforeClass() throws Exception { - assumeFalse( - "PgNumeric is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator()); testHelper = env.getTestHelper(); databaseAdminClient = testHelper.getClient().getDatabaseAdminClient(); databasesToDrop = new ArrayList<>(); @@ -116,8 +112,6 @@ public void setUp() throws Exception { @Test public void testLiteralPgNumeric() { - assumeFalse( - "PgNumeric is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator()); databaseClient .readWriteTransaction() .run( @@ -134,7 +128,9 @@ public void testLiteralPgNumeric() { }); try (ResultSet resultSet = - databaseClient.singleUse().executeQuery(Statement.of("SELECT * FROM " + tableName))) { + databaseClient + .singleUse() + .executeQuery(Statement.of("SELECT * FROM " + tableName + " ORDER BY id"))) { resultSet.next(); assertEquals("1.23", resultSet.getString("col1")); @@ -151,8 +147,6 @@ public void testLiteralPgNumeric() { @Test public void testParameterizedWithPgNumericAsValue() { - assumeFalse( - "PgNumeric is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator()); databaseClient .readWriteTransaction() .run( @@ -176,7 +170,9 @@ public void testParameterizedWithPgNumericAsValue() { }); try (ResultSet resultSet = - databaseClient.singleUse().executeQuery(Statement.of("SELECT * FROM " + tableName))) { + databaseClient + .singleUse() + .executeQuery(Statement.of("SELECT * FROM " + tableName + " ORDER BY id"))) { resultSet.next(); assertEquals("1.23", resultSet.getString("col1")); @@ -193,8 +189,6 @@ public void testParameterizedWithPgNumericAsValue() { @Test public void testParameterizedWithPgNumericAsDouble() { - assumeFalse( - "PgNumeric is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator()); databaseClient .readWriteTransaction() .run( @@ -218,7 +212,9 @@ public void testParameterizedWithPgNumericAsDouble() { }); try (ResultSet resultSet = - databaseClient.singleUse().executeQuery(Statement.of("SELECT * FROM " + tableName))) { + databaseClient + .singleUse() + .executeQuery(Statement.of("SELECT * FROM " + tableName + " ORDER BY id"))) { resultSet.next(); assertEquals("1.23", resultSet.getString("col1")); @@ -235,8 +231,6 @@ public void testParameterizedWithPgNumericAsDouble() { @Test public void testParameterizedWithPgNumericAsInt() { - assumeFalse( - "PgNumeric is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator()); databaseClient .readWriteTransaction() .run( @@ -260,8 +254,6 @@ public void testParameterizedWithPgNumericAsInt() { @Test public void testParameterizedWithPgNumericAsLong() { - assumeFalse( - "PgNumeric is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator()); databaseClient .readWriteTransaction() .run( @@ -285,8 +277,6 @@ public void testParameterizedWithPgNumericAsLong() { @Test public void testMutationsWithPgNumericAsString() { - assumeFalse( - "PgNumeric is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator()); databaseClient .readWriteTransaction() .run( @@ -315,7 +305,9 @@ public void testMutationsWithPgNumericAsString() { }); try (ResultSet resultSet = - databaseClient.singleUse().executeQuery(Statement.of("SELECT * FROM " + tableName))) { + databaseClient + .singleUse() + .executeQuery(Statement.of("SELECT * FROM " + tableName + " ORDER BY id"))) { resultSet.next(); assertEquals("1.23", resultSet.getString("col1")); @@ -332,8 +324,6 @@ public void testMutationsWithPgNumericAsString() { @Test public void testMutationsWithPgNumericAsInt() { - assumeFalse( - "PgNumeric is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator()); databaseClient .readWriteTransaction() .run( @@ -360,8 +350,6 @@ public void testMutationsWithPgNumericAsInt() { @Test public void testMutationsWithPgNumericAsLong() { - assumeFalse( - "PgNumeric is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator()); databaseClient .readWriteTransaction() .run( @@ -388,8 +376,6 @@ public void testMutationsWithPgNumericAsLong() { @Test public void testMutationsWithPgNumericAsBigDecimal() { - assumeFalse( - "PgNumeric is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator()); databaseClient .readWriteTransaction() .run( @@ -412,7 +398,9 @@ public void testMutationsWithPgNumericAsBigDecimal() { }); try (ResultSet resultSet = - databaseClient.singleUse().executeQuery(Statement.of("SELECT * FROM " + tableName))) { + databaseClient + .singleUse() + .executeQuery(Statement.of("SELECT * FROM " + tableName + " ORDER BY id"))) { resultSet.next(); assertEquals("1.23", resultSet.getString("col1")); @@ -425,8 +413,6 @@ public void testMutationsWithPgNumericAsBigDecimal() { @Test public void testMutationsWithPgNumericAsValue() { - assumeFalse( - "PgNumeric is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator()); databaseClient .readWriteTransaction() .run( @@ -455,7 +441,9 @@ public void testMutationsWithPgNumericAsValue() { }); try (ResultSet resultSet = - databaseClient.singleUse().executeQuery(Statement.of("SELECT * FROM " + tableName))) { + databaseClient + .singleUse() + .executeQuery(Statement.of("SELECT * FROM " + tableName + " ORDER BY id"))) { resultSet.next(); assertEquals("1.23", resultSet.getString("col1")); From 3f4873dbf6382df5acad1c6972248647ee5f40a1 Mon Sep 17 00:00:00 2001 From: Sakthivel Subramanian <179120858+sakthivelmanii@users.noreply.github.com> Date: Tue, 10 Dec 2024 08:34:27 +0530 Subject: [PATCH 10/14] ci(spanner): Fix nightly job issues (#3522) * ci(spanner): Fix nightly job permission issue * update scope for surefire-junit4 --- google-cloud-spanner-executor/pom.xml | 9 ++++++++- .../cloud/spanner/it/slow/ITBackupTest.java | 2 +- samples/install-without-bom/pom.xml | 6 +++--- samples/snapshot/pom.xml | 6 +++--- samples/snippets/pom.xml | 6 +++--- .../spanner/AddAndDropDatabaseRole.java | 20 +++++++++++-------- .../com/example/spanner/PgSpannerSample.java | 4 ++-- .../archived/AddAndDropDatabaseRole.java | 1 + .../admin/archived/CreateSequenceSample.java | 2 +- .../admin/archived/PgSpannerSample.java | 5 ++--- ...eateIncrementalBackupScheduleSampleIT.java | 6 +++--- .../CreateInstancePartitionSampleIT.java | 2 ++ .../com/example/spanner/DatabaseRolesIT.java | 3 ++- .../com/example/spanner/SampleTestBaseV2.java | 1 + .../example/spanner/SpannerGraphSampleIT.java | 2 +- .../com/example/spanner/SpannerSampleIT.java | 5 +++++ .../CustomInstanceConfigSampleIT.java | 2 +- .../admin/archived/DatabaseRolesIT.java | 5 ++++- .../admin/archived/PgSpannerSampleIT.java | 2 +- 19 files changed, 56 insertions(+), 33 deletions(-) diff --git a/google-cloud-spanner-executor/pom.xml b/google-cloud-spanner-executor/pom.xml index 1c45d6915fd..ccb631bb1a2 100644 --- a/google-cloud-spanner-executor/pom.xml +++ b/google-cloud-spanner-executor/pom.xml @@ -189,6 +189,13 @@ test + + org.apache.maven.surefire + surefire-junit4 + 3.5.2 + test + + @@ -259,7 +266,7 @@ org.apache.maven.plugins maven-dependency-plugin - com.google.api:gax + com.google.api:gax,org.apache.maven.surefire:surefire-junit4 diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/slow/ITBackupTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/slow/ITBackupTest.java index 9deb3289e07..1359046aee0 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/slow/ITBackupTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/slow/ITBackupTest.java @@ -717,7 +717,7 @@ private void testPagination() { Page page = dbAdminClient.listBackups(instanceId, Options.pageSize(1)); assertEquals(1, Iterables.size(page.getValues())); numBackups++; - assertTrue(page.hasNextPage()); + assertFalse(page.hasNextPage()); Set seenPageTokens = new HashSet<>(); seenPageTokens.add(""); while (page.hasNextPage()) { diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 4de16e06367..cc7900ed246 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -148,12 +148,12 @@ 3.5.2 - java-client-integration-tests + java-sample-integration-tests java-client-mr-integration-tests nam11 us-east1 - java-client-integration-test-cmek-ring - java-client-integration-test-cmek-key + cmek-test-key-ring + cmek-test-key mysample quick-db diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index cca1680ac10..9a6e4d0e30e 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -147,12 +147,12 @@ 3.5.2 - java-client-integration-tests + java-sample-integration-tests java-client-mr-integration-tests nam11 us-east1 - java-client-integration-test-cmek-ring - java-client-integration-test-cmek-key + cmek-test-key-ring + cmek-test-key mysample mysample-instance quick-db diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 06698627ef9..df0488ac116 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -178,12 +178,12 @@ 3.5.2 - java-client-integration-tests + java-sample-integration-tests java-client-mr-integration-tests nam11 us-east1 - java-client-integration-test-cmek-ring - java-client-integration-test-cmek-key + cmek-test-key-ring + cmek-test-key mysample quick-db diff --git a/samples/snippets/src/main/java/com/example/spanner/AddAndDropDatabaseRole.java b/samples/snippets/src/main/java/com/example/spanner/AddAndDropDatabaseRole.java index 75e85f5f85c..d3de612098d 100644 --- a/samples/snippets/src/main/java/com/example/spanner/AddAndDropDatabaseRole.java +++ b/samples/snippets/src/main/java/com/example/spanner/AddAndDropDatabaseRole.java @@ -23,6 +23,8 @@ import com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient; import com.google.common.collect.ImmutableList; import com.google.spanner.admin.database.v1.DatabaseName; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; @@ -36,12 +38,12 @@ static void addAndDropDatabaseRole() { String databaseId = "my-database"; String parentRole = "parent_role"; String childRole = "child_role"; - addAndDropDatabaseRole(projectId, instanceId, databaseId, parentRole, childRole); + addAndDropDatabaseRole(projectId, instanceId, databaseId, parentRole, childRole, "Albums"); } static void addAndDropDatabaseRole( String projectId, String instanceId, String databaseId, - String parentRole, String childRole) { + String parentRole, String childRole, String... tables) { try (Spanner spanner = SpannerOptions.newBuilder() .setProjectId(projectId) @@ -49,13 +51,15 @@ static void addAndDropDatabaseRole( .getService(); DatabaseAdminClient databaseAdminClient = spanner.createDatabaseAdminClient()) { System.out.println("Waiting for role create operation to complete..."); + List roleStatements = new ArrayList<>(ImmutableList.of( + String.format("CREATE ROLE %s", parentRole), + String.format("CREATE ROLE %s", childRole), + String.format("GRANT ROLE %s TO ROLE %s", parentRole, childRole))); + for (String table : tables) { + roleStatements.add(String.format("GRANT SELECT ON TABLE %s TO ROLE %s", table, parentRole)); + } databaseAdminClient.updateDatabaseDdlAsync( - DatabaseName.of(projectId, instanceId, databaseId), - ImmutableList.of( - String.format("CREATE ROLE %s", parentRole), - String.format("GRANT SELECT ON TABLE Albums TO ROLE %s", parentRole), - String.format("CREATE ROLE %s", childRole), - String.format("GRANT ROLE %s TO ROLE %s", parentRole, childRole))) + DatabaseName.of(projectId, instanceId, databaseId), roleStatements) .get(5, TimeUnit.MINUTES); System.out.printf( "Created roles %s and %s and granted privileges%n", parentRole, childRole); diff --git a/samples/snippets/src/main/java/com/example/spanner/PgSpannerSample.java b/samples/snippets/src/main/java/com/example/spanner/PgSpannerSample.java index 600206c1481..b3ad5cd08c4 100644 --- a/samples/snippets/src/main/java/com/example/spanner/PgSpannerSample.java +++ b/samples/snippets/src/main/java/com/example/spanner/PgSpannerSample.java @@ -631,7 +631,7 @@ static void writeWithTransactionUsingDml(DatabaseClient dbClient) { Statement updateStatement = Statement.newBuilder( "UPDATE Albums " - + "SET MarketingBudget = $1" + + "SET MarketingBudget = $1 " + "WHERE SingerId = 1 and AlbumId = 1") .bind("p1") .to(album1Budget) @@ -640,7 +640,7 @@ static void writeWithTransactionUsingDml(DatabaseClient dbClient) { Statement updateStatement2 = Statement.newBuilder( "UPDATE Albums " - + "SET MarketingBudget = $1" + + "SET MarketingBudget = $1 " + "WHERE SingerId = 2 and AlbumId = 2") .bind("p1") .to(album2Budget) diff --git a/samples/snippets/src/main/java/com/example/spanner/admin/archived/AddAndDropDatabaseRole.java b/samples/snippets/src/main/java/com/example/spanner/admin/archived/AddAndDropDatabaseRole.java index cce8543492e..8df22402c21 100644 --- a/samples/snippets/src/main/java/com/example/spanner/admin/archived/AddAndDropDatabaseRole.java +++ b/samples/snippets/src/main/java/com/example/spanner/admin/archived/AddAndDropDatabaseRole.java @@ -53,6 +53,7 @@ static void addAndDropDatabaseRole( databaseId, ImmutableList.of( "CREATE ROLE " + parentRole, + "GRANT SELECT ON TABLE Singers TO ROLE " + parentRole, "GRANT SELECT ON TABLE Albums TO ROLE " + parentRole, "CREATE ROLE " + childRole, "GRANT ROLE " + parentRole + " TO ROLE " + childRole), diff --git a/samples/snippets/src/main/java/com/example/spanner/admin/archived/CreateSequenceSample.java b/samples/snippets/src/main/java/com/example/spanner/admin/archived/CreateSequenceSample.java index 637bd39d9a1..d0172eb2d53 100644 --- a/samples/snippets/src/main/java/com/example/spanner/admin/archived/CreateSequenceSample.java +++ b/samples/snippets/src/main/java/com/example/spanner/admin/archived/CreateSequenceSample.java @@ -58,7 +58,7 @@ static void createSequence(String projectId, String instanceId, String databaseI .get(5, TimeUnit.MINUTES); System.out.println( - "Created Seq sequence and Customers table, where the key column CustomerId " + "Created Seq sequence and Customers table, where its key column CustomerId " + "uses the sequence as a default value"); final DatabaseClient dbClient = diff --git a/samples/snippets/src/main/java/com/example/spanner/admin/archived/PgSpannerSample.java b/samples/snippets/src/main/java/com/example/spanner/admin/archived/PgSpannerSample.java index 8a95cebef04..0ab3a75c967 100644 --- a/samples/snippets/src/main/java/com/example/spanner/admin/archived/PgSpannerSample.java +++ b/samples/snippets/src/main/java/com/example/spanner/admin/archived/PgSpannerSample.java @@ -203,7 +203,6 @@ static void createPostgreSqlDatabase(DatabaseAdminClient dbAdminClient, Database // Initiate the request which returns an OperationFuture. Database db = op.get(); System.out.println("Created database [" + db.getId() + "]"); - createTableUsingDdl(dbAdminClient, id); } catch (ExecutionException e) { // If the operation failed during execution, expose the cause. throw (SpannerException) e.getCause(); @@ -633,7 +632,7 @@ static void writeWithTransactionUsingDml(DatabaseClient dbClient) { Statement updateStatement = Statement.newBuilder( "UPDATE Albums " - + "SET MarketingBudget = $1" + + "SET MarketingBudget = $1 " + "WHERE SingerId = 1 and AlbumId = 1") .bind("p1") .to(album1Budget) @@ -642,7 +641,7 @@ static void writeWithTransactionUsingDml(DatabaseClient dbClient) { Statement updateStatement2 = Statement.newBuilder( "UPDATE Albums " - + "SET MarketingBudget = $1" + + "SET MarketingBudget = $1 " + "WHERE SingerId = 2 and AlbumId = 2") .bind("p1") .to(album2Budget) diff --git a/samples/snippets/src/test/java/com/example/spanner/CreateIncrementalBackupScheduleSampleIT.java b/samples/snippets/src/test/java/com/example/spanner/CreateIncrementalBackupScheduleSampleIT.java index 74136562e10..5d590a5b382 100644 --- a/samples/snippets/src/test/java/com/example/spanner/CreateIncrementalBackupScheduleSampleIT.java +++ b/samples/snippets/src/test/java/com/example/spanner/CreateIncrementalBackupScheduleSampleIT.java @@ -33,16 +33,16 @@ public class CreateIncrementalBackupScheduleSampleIT extends SampleTestBaseV2 { public void testCreateIncrementalBackupScheduleSample() throws Exception { String backupScheduleId = String.format("schedule-%s", UUID.randomUUID()); BackupScheduleName backupScheduleName = - BackupScheduleName.of(projectId, instanceId, databaseId, backupScheduleId); + BackupScheduleName.of(projectId, multiRegionalInstanceId, databaseId, backupScheduleId); String out = SampleRunner.runSample( () -> { try { CreateIncrementalBackupScheduleSample.createIncrementalBackupSchedule( - projectId, instanceId, databaseId, backupScheduleId); + projectId, multiRegionalInstanceId, databaseId, backupScheduleId); } finally { DeleteBackupScheduleSample.deleteBackupSchedule( - projectId, instanceId, databaseId, backupScheduleId); + projectId, multiRegionalInstanceId, databaseId, backupScheduleId); } }); assertThat(out) diff --git a/samples/snippets/src/test/java/com/example/spanner/CreateInstancePartitionSampleIT.java b/samples/snippets/src/test/java/com/example/spanner/CreateInstancePartitionSampleIT.java index 3038d29750d..b243a9229d2 100644 --- a/samples/snippets/src/test/java/com/example/spanner/CreateInstancePartitionSampleIT.java +++ b/samples/snippets/src/test/java/com/example/spanner/CreateInstancePartitionSampleIT.java @@ -22,6 +22,7 @@ import com.google.cloud.spanner.InstanceConfigId; import com.google.cloud.spanner.InstanceId; import com.google.cloud.spanner.InstanceInfo; +import com.google.spanner.admin.instance.v1.Instance.Edition; import com.google.spanner.admin.instance.v1.InstancePartitionName; import org.junit.Test; @@ -34,6 +35,7 @@ public void testCreateInstancePartition() throws Exception { instanceAdminClient .createInstance( InstanceInfo.newBuilder(InstanceId.of(projectId, instanceId)) + .setEdition(Edition.ENTERPRISE_PLUS) .setDisplayName("Geo-partitioning test instance") .setInstanceConfigId(InstanceConfigId.of(projectId, "regional-us-central1")) .setNodeCount(1) diff --git a/samples/snippets/src/test/java/com/example/spanner/DatabaseRolesIT.java b/samples/snippets/src/test/java/com/example/spanner/DatabaseRolesIT.java index 6c2b41c3672..4b9013e62f4 100644 --- a/samples/snippets/src/test/java/com/example/spanner/DatabaseRolesIT.java +++ b/samples/snippets/src/test/java/com/example/spanner/DatabaseRolesIT.java @@ -108,7 +108,8 @@ public void testAddAndDropDatabaseRole() throws Exception { SampleRunner.runSample( () -> AddAndDropDatabaseRole.addAndDropDatabaseRole( - projectId, instanceId, databaseId.getDatabase(), "new_parent", "new_child")); + projectId, instanceId, databaseId.getDatabase(), "new_parent", "new_child", + "Singers", "Albums")); assertTrue(out.contains("Created roles new_parent and new_child and granted privileges")); assertTrue(out.contains("Revoked privileges and dropped role new_child")); } diff --git a/samples/snippets/src/test/java/com/example/spanner/SampleTestBaseV2.java b/samples/snippets/src/test/java/com/example/spanner/SampleTestBaseV2.java index 909e79738b8..5a43261269d 100644 --- a/samples/snippets/src/test/java/com/example/spanner/SampleTestBaseV2.java +++ b/samples/snippets/src/test/java/com/example/spanner/SampleTestBaseV2.java @@ -140,6 +140,7 @@ public static void afterClass() throws InterruptedException { } } + spanner.close(); databaseAdminClient.close(); instanceAdminClient.close(); diff --git a/samples/snippets/src/test/java/com/example/spanner/SpannerGraphSampleIT.java b/samples/snippets/src/test/java/com/example/spanner/SpannerGraphSampleIT.java index 6f778de49ab..be6e67282ab 100644 --- a/samples/snippets/src/test/java/com/example/spanner/SpannerGraphSampleIT.java +++ b/samples/snippets/src/test/java/com/example/spanner/SpannerGraphSampleIT.java @@ -34,7 +34,7 @@ public class SpannerGraphSampleIT extends SampleTestBaseV2 { private static final int DBID_LENGTH = 20; // The instance needs to exist for tests to pass. - private static final String instanceId = System.getProperty("spanner.test.instance"); + private static final String instanceId = System.getProperty("spanner.test.instance.mr"); private static final String baseDbId = System.getProperty("spanner.sample.database"); static Spanner spanner; static DatabaseAdminClient databaseAdminClient; diff --git a/samples/snippets/src/test/java/com/example/spanner/SpannerSampleIT.java b/samples/snippets/src/test/java/com/example/spanner/SpannerSampleIT.java index 4e02f714e39..d59152b407c 100644 --- a/samples/snippets/src/test/java/com/example/spanner/SpannerSampleIT.java +++ b/samples/snippets/src/test/java/com/example/spanner/SpannerSampleIT.java @@ -527,6 +527,7 @@ public void testEncryptedDatabaseAndBackupSamples() throws Exception { .setNodeCount(1) .build()) .get(); + System.out.println("Creating database ..."); try { String out = SampleRunner.runSample( @@ -538,6 +539,7 @@ public void testEncryptedDatabaseAndBackupSamples() throws Exception { String.format( "Created database [%s]", DatabaseName.of(projectId, instanceId, databaseId))); + System.out.println("Creating backup with encryption key ..."); out = SampleRunner.runSampleWithRetry( () -> @@ -556,6 +558,7 @@ public void testEncryptedDatabaseAndBackupSamples() throws Exception { + "was created at (.*) using encryption key %s", projectId, instanceId, encryptedBackupId, key)); + System.out.println("Restoring backup with encryption key ..."); out = SampleRunner.runSampleWithRetry( () -> @@ -587,6 +590,7 @@ public void testEncryptedDatabaseAndBackupSamples() throws Exception { } finally { // Delete the backups from the test instance first, as the instance can only be deleted once // all backups have been deleted. + System.out.println("Deleting backups ..."); deleteAllBackups(instanceId); instanceAdminClient.deleteInstance(instanceId); } @@ -633,6 +637,7 @@ private static void deleteAllBackups(String instanceId) throws InterruptedExcept InstanceName instanceName = InstanceName.of(projectId, instanceId); for (Backup backup : databaseAdminClient.listBackups(instanceName.toString()).iterateAll()) { int attempts = 0; + System.out.printf("Deleting backup ... %s%n", backup.getName()); while (attempts < 30) { try { attempts++; diff --git a/samples/snippets/src/test/java/com/example/spanner/admin/archived/CustomInstanceConfigSampleIT.java b/samples/snippets/src/test/java/com/example/spanner/admin/archived/CustomInstanceConfigSampleIT.java index a56b72b75f1..c8271225ccb 100644 --- a/samples/snippets/src/test/java/com/example/spanner/admin/archived/CustomInstanceConfigSampleIT.java +++ b/samples/snippets/src/test/java/com/example/spanner/admin/archived/CustomInstanceConfigSampleIT.java @@ -41,7 +41,7 @@ public void testCustomInstanceConfigOperations() throws Exception { SampleRunner.runSample( () -> ListInstanceConfigOperationsSample.listInstanceConfigOperations(projectId)); - assertTrue(out2.contains("List instance config operation")); + assertTrue(out2.contains("Create instance config operation")); // Update display name to a randomly generated instance config id. final String out3 = diff --git a/samples/snippets/src/test/java/com/example/spanner/admin/archived/DatabaseRolesIT.java b/samples/snippets/src/test/java/com/example/spanner/admin/archived/DatabaseRolesIT.java index 3e40189d946..f1bad568978 100644 --- a/samples/snippets/src/test/java/com/example/spanner/admin/archived/DatabaseRolesIT.java +++ b/samples/snippets/src/test/java/com/example/spanner/admin/archived/DatabaseRolesIT.java @@ -31,12 +31,15 @@ import org.junit.After; import org.junit.Before; import org.junit.BeforeClass; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; +import org.junit.runners.MethodSorters; /** Integration tests for FGAC samples for GoogleStandardSql dialect. */ @RunWith(JUnit4.class) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class DatabaseRolesIT extends SampleTestBase { private static DatabaseId databaseId; @@ -105,7 +108,7 @@ public void testAddAndDropDatabaseRole() throws Exception { SampleRunner.runSample( () -> AddAndDropDatabaseRole.addAndDropDatabaseRole( - projectId, instanceId, databaseId.getDatabase(), "new-parent", "new-child")); + projectId, instanceId, databaseId.getDatabase(), "new_parent", "new_child")); assertTrue(out.contains("Created roles new_parent and new_child and granted privileges")); assertTrue(out.contains("Revoked privileges and dropped role new_child")); } diff --git a/samples/snippets/src/test/java/com/example/spanner/admin/archived/PgSpannerSampleIT.java b/samples/snippets/src/test/java/com/example/spanner/admin/archived/PgSpannerSampleIT.java index 72900b5e417..c4ba80f3f80 100644 --- a/samples/snippets/src/test/java/com/example/spanner/admin/archived/PgSpannerSampleIT.java +++ b/samples/snippets/src/test/java/com/example/spanner/admin/archived/PgSpannerSampleIT.java @@ -130,7 +130,7 @@ public void testSample() throws Exception { assertThat(databaseId).isNotNull(); System.out.println("Create Database ..."); - String out = runSample("createpgdatabase"); + String out = runSample("createdatabase"); assertThat(out).contains("Created database"); assertThat(out).contains(dbId.getName()); From 46464fca396994a7b46f66a0d46a9391dc1c36c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Olav=20L=C3=B8ite?= Date: Tue, 10 Dec 2024 10:28:58 +0100 Subject: [PATCH 11/14] chore: add internal option for statement executor type (#3534) The Connection API by default uses either a platform thread or a virtual thread for each connection to execute and control the statements of that connection. This is used to enable asynchronous execution of statements and allows a statement to be cancelled by just interrupting this thread. Both these use cases are however not (or only very rarely) used by the most common users of the Connection API; the JDBC driver and PGAdapter. PGAdapter uses the PostgreSQL wire-protocol, which by design is synchronous, and JDBC is also a synchronous API. The latter has a cancel() method that currently requires this threading model, but this can be modified in the JDBC driver. Using a direct executor instead of a single-threaded executor per connection can save one thread per connection. The option is intentionally made package-private, so the above-mentioned frameworks can set it by default without it becoming part of the public API. --- .../spanner/connection/ConnectionImpl.java | 19 +++++- .../spanner/connection/ConnectionOptions.java | 13 ++++ .../spanner/connection/StatementExecutor.java | 23 +++++-- .../connection/AbstractMockServerTest.java | 6 ++ .../ConnectionAsyncApiAbortedTest.java | 7 ++ .../connection/ConnectionAsyncApiTest.java | 7 ++ .../spanner/connection/ConnectionTest.java | 7 ++ .../connection/StatementTimeoutTest.java | 64 ++++++++++++++++++- 8 files changed, 136 insertions(+), 10 deletions(-) diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionImpl.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionImpl.java index d7a1052d1c1..25ee8b39af4 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionImpl.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionImpl.java @@ -76,6 +76,7 @@ import com.google.cloud.spanner.connection.AbstractStatementParser.StatementType; import com.google.cloud.spanner.connection.ConnectionProperty.Context; import com.google.cloud.spanner.connection.ConnectionState.Type; +import com.google.cloud.spanner.connection.StatementExecutor.StatementExecutorType; import com.google.cloud.spanner.connection.StatementExecutor.StatementTimeout; import com.google.cloud.spanner.connection.StatementResult.ResultType; import com.google.cloud.spanner.connection.UnitOfWork.CallType; @@ -284,9 +285,17 @@ static UnitOfWorkType of(TransactionMode transactionMode) { Preconditions.checkNotNull(options); this.leakedException = options.isTrackConnectionLeaks() ? new LeakedConnectionException() : null; + StatementExecutorType statementExecutorType; + if (options.getStatementExecutorType() != null) { + statementExecutorType = options.getStatementExecutorType(); + } else { + statementExecutorType = + options.isUseVirtualThreads() + ? StatementExecutorType.VIRTUAL_THREAD + : StatementExecutorType.DIRECT_EXECUTOR; + } this.statementExecutor = - new StatementExecutor( - options.isUseVirtualThreads(), options.getStatementExecutionInterceptors()); + new StatementExecutor(statementExecutorType, options.getStatementExecutionInterceptors()); this.spannerPool = SpannerPool.INSTANCE; this.options = options; this.spanner = spannerPool.getSpanner(options, this); @@ -330,7 +339,11 @@ && getDialect() == Dialect.POSTGRESQL this.leakedException = options.isTrackConnectionLeaks() ? new LeakedConnectionException() : null; this.statementExecutor = - new StatementExecutor(options.isUseVirtualThreads(), Collections.emptyList()); + new StatementExecutor( + options.isUseVirtualThreads() + ? StatementExecutorType.VIRTUAL_THREAD + : StatementExecutorType.DIRECT_EXECUTOR, + Collections.emptyList()); this.spannerPool = Preconditions.checkNotNull(spannerPool); this.options = Preconditions.checkNotNull(options); this.spanner = spannerPool.getSpanner(options, this); diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionOptions.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionOptions.java index 66b09c35afd..2be2d7980b2 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionOptions.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionOptions.java @@ -70,6 +70,7 @@ import com.google.cloud.spanner.SpannerException; import com.google.cloud.spanner.SpannerExceptionFactory; import com.google.cloud.spanner.SpannerOptions; +import com.google.cloud.spanner.connection.StatementExecutor.StatementExecutorType; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.base.Strings; @@ -614,6 +615,7 @@ public static class Builder { new HashMap<>(); private String uri; private Credentials credentials; + private StatementExecutorType statementExecutorType; private SessionPoolOptions sessionPoolOptions; private List statementExecutionInterceptors = Collections.emptyList(); @@ -777,6 +779,11 @@ Builder setCredentials(Credentials credentials) { return this; } + Builder setStatementExecutorType(StatementExecutorType statementExecutorType) { + this.statementExecutorType = statementExecutorType; + return this; + } + public Builder setOpenTelemetry(OpenTelemetry openTelemetry) { this.openTelemetry = openTelemetry; return this; @@ -814,6 +821,7 @@ public static Builder newBuilder() { private final String instanceId; private final String databaseName; private final Credentials credentials; + private final StatementExecutorType statementExecutorType; private final SessionPoolOptions sessionPoolOptions; private final OpenTelemetry openTelemetry; @@ -834,6 +842,7 @@ private ConnectionOptions(Builder builder) { ConnectionPropertyValue value = cast(connectionPropertyValues.get(LENIENT.getKey())); this.warnings = checkValidProperties(value != null && value.getValue(), uri); this.fixedCredentials = builder.credentials; + this.statementExecutorType = builder.statementExecutorType; this.openTelemetry = builder.openTelemetry; this.statementExecutionInterceptors = @@ -1105,6 +1114,10 @@ CredentialsProvider getCredentialsProvider() { return getInitialConnectionPropertyValue(CREDENTIALS_PROVIDER); } + StatementExecutorType getStatementExecutorType() { + return this.statementExecutorType; + } + /** The {@link SessionPoolOptions} of this {@link ConnectionOptions}. */ public SessionPoolOptions getSessionPoolOptions() { return sessionPoolOptions; diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/StatementExecutor.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/StatementExecutor.java index b92e575a047..7340834a926 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/StatementExecutor.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/StatementExecutor.java @@ -146,7 +146,10 @@ java.time.Duration asDuration() { ThreadFactoryUtil.createVirtualOrPlatformDaemonThreadFactory("connection-executor", false); /** Creates an {@link ExecutorService} for a {@link StatementExecutor}. */ - private static ListeningExecutorService createExecutorService(boolean useVirtualThreads) { + private static ListeningExecutorService createExecutorService(StatementExecutorType type) { + if (type == StatementExecutorType.DIRECT_EXECUTOR) { + return MoreExecutors.newDirectExecutorService(); + } return MoreExecutors.listeningDecorator( Context.taskWrapping( new ThreadPoolExecutor( @@ -155,7 +158,7 @@ private static ListeningExecutorService createExecutorService(boolean useVirtual 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), - useVirtualThreads + type == StatementExecutorType.VIRTUAL_THREAD ? DEFAULT_VIRTUAL_THREAD_FACTORY : DEFAULT_DAEMON_THREAD_FACTORY))); } @@ -168,13 +171,23 @@ private static ListeningExecutorService createExecutorService(boolean useVirtual */ private final List interceptors; + enum StatementExecutorType { + PLATFORM_THREAD, + VIRTUAL_THREAD, + DIRECT_EXECUTOR, + } + @VisibleForTesting StatementExecutor() { - this(DEFAULT_USE_VIRTUAL_THREADS, Collections.emptyList()); + this( + DEFAULT_USE_VIRTUAL_THREADS + ? StatementExecutorType.VIRTUAL_THREAD + : StatementExecutorType.PLATFORM_THREAD, + Collections.emptyList()); } - StatementExecutor(boolean useVirtualThreads, List interceptors) { - this.executor = createExecutorService(useVirtualThreads); + StatementExecutor(StatementExecutorType type, List interceptors) { + this.executor = createExecutorService(type); this.interceptors = Collections.unmodifiableList(interceptors); } diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/AbstractMockServerTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/AbstractMockServerTest.java index 375fdda2a95..fa3ab00b138 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/AbstractMockServerTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/AbstractMockServerTest.java @@ -283,6 +283,7 @@ ITConnection createConnection( ConnectionOptions.newBuilder() .setUri(getBaseUrl() + additionalUrlOptions) .setStatementExecutionInterceptors(interceptors); + configureConnectionOptions(builder); ConnectionOptions options = builder.build(); ITConnection connection = createITConnection(options); for (TransactionRetryListener listener : transactionRetryListeners) { @@ -291,6 +292,11 @@ ITConnection createConnection( return connection; } + protected ConnectionOptions.Builder configureConnectionOptions( + ConnectionOptions.Builder builder) { + return builder; + } + protected String getBaseUrl() { return String.format( "cloudspanner://localhost:%d/projects/proj/instances/inst/databases/db?usePlainText=true;autocommit=false;retryAbortsInternally=true", diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ConnectionAsyncApiAbortedTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ConnectionAsyncApiAbortedTest.java index 97d745edd7f..1f4378ecd86 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ConnectionAsyncApiAbortedTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ConnectionAsyncApiAbortedTest.java @@ -32,7 +32,9 @@ import com.google.cloud.spanner.Options; import com.google.cloud.spanner.SpannerExceptionFactory; import com.google.cloud.spanner.Statement; +import com.google.cloud.spanner.connection.ConnectionOptions.Builder; import com.google.cloud.spanner.connection.ITAbstractSpannerTest.ITConnection; +import com.google.cloud.spanner.connection.StatementExecutor.StatementExecutorType; import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; @@ -127,6 +129,11 @@ ITConnection createConnection(TransactionRetryListener listener) { return connection; } + @Override + protected Builder configureConnectionOptions(Builder builder) { + return builder.setStatementExecutorType(StatementExecutorType.PLATFORM_THREAD); + } + @Test public void testSingleQueryAborted() { RetryCounter counter = new RetryCounter(); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ConnectionAsyncApiTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ConnectionAsyncApiTest.java index 21fe086d4f8..c6777da5b51 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ConnectionAsyncApiTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ConnectionAsyncApiTest.java @@ -36,7 +36,9 @@ import com.google.cloud.spanner.SpannerApiFutures; import com.google.cloud.spanner.SpannerException; import com.google.cloud.spanner.Statement; +import com.google.cloud.spanner.connection.ConnectionOptions.Builder; import com.google.cloud.spanner.connection.SpannerPool.CheckAndCloseSpannersMode; +import com.google.cloud.spanner.connection.StatementExecutor.StatementExecutorType; import com.google.cloud.spanner.connection.StatementResult.ResultType; import com.google.common.base.Function; import com.google.common.collect.Collections2; @@ -86,6 +88,11 @@ public void setup() { } } + @Override + protected Builder configureConnectionOptions(Builder builder) { + return builder.setStatementExecutorType(StatementExecutorType.PLATFORM_THREAD); + } + @After public void reset() { mockSpanner.removeAllExecutionTimes(); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ConnectionTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ConnectionTest.java index c5b34982255..9ae174bd403 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ConnectionTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ConnectionTest.java @@ -36,6 +36,8 @@ import com.google.cloud.spanner.SpannerOptions; import com.google.cloud.spanner.Statement; import com.google.cloud.spanner.TimestampBound; +import com.google.cloud.spanner.connection.ConnectionOptions.Builder; +import com.google.cloud.spanner.connection.StatementExecutor.StatementExecutorType; import com.google.common.collect.ImmutableList; import com.google.spanner.v1.BatchCreateSessionsRequest; import com.google.spanner.v1.CommitRequest; @@ -417,6 +419,11 @@ protected String getBaseUrl() { return super.getBaseUrl() + ";maxSessions=1"; } + @Override + protected Builder configureConnectionOptions(Builder builder) { + return builder.setStatementExecutorType(StatementExecutorType.PLATFORM_THREAD); + } + @Test public void testMaxSessions() throws InterruptedException, TimeoutException, ExecutionException { diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/StatementTimeoutTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/StatementTimeoutTest.java index f55c55c6c93..a50fb98f1e3 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/StatementTimeoutTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/StatementTimeoutTest.java @@ -23,6 +23,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; +import static org.junit.Assume.assumeFalse; import com.google.api.core.SettableApiFuture; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; @@ -35,6 +36,7 @@ import com.google.cloud.spanner.Statement; import com.google.cloud.spanner.connection.AbstractConnectionImplTest.ConnectionConsumer; import com.google.cloud.spanner.connection.ITAbstractSpannerTest.ITConnection; +import com.google.cloud.spanner.connection.StatementExecutor.StatementExecutorType; import com.google.common.base.Stopwatch; import com.google.common.collect.Collections2; import com.google.longrunning.Operation; @@ -58,9 +60,11 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameter; +import org.junit.runners.Parameterized.Parameters; -@RunWith(JUnit4.class) +@RunWith(Parameterized.class) public class StatementTimeoutTest extends AbstractMockServerTest { private static final String SLOW_SELECT = "SELECT foo FROM bar"; @@ -85,10 +89,18 @@ public class StatementTimeoutTest extends AbstractMockServerTest { */ private static final int TIMEOUT_FOR_SLOW_STATEMENTS = 50; + @Parameters(name = "statementExecutorType = {0}") + public static Object[] parameters() { + return StatementExecutorType.values(); + } + + @Parameter public StatementExecutorType statementExecutorType; + protected ITConnection createConnection() { ConnectionOptions options = ConnectionOptions.newBuilder() .setUri(getBaseUrl() + ";trackSessionLeaks=false") + .setStatementExecutorType(statementExecutorType) .setConfigurator( optionsConfigurator -> optionsConfigurator @@ -618,6 +630,10 @@ private void waitForDdlRequestOnServer() { @Test public void testCancelReadOnlyAutocommit() { + assumeFalse( + "Direct executor does not yet support cancelling statements", + statementExecutorType == StatementExecutorType.DIRECT_EXECUTOR); + mockSpanner.setExecuteStreamingSqlExecutionTime( SimulatedExecutionTime.ofMinimumAndRandomTime(EXECUTION_TIME_SLOW_STATEMENT, 0)); @@ -643,6 +659,10 @@ public void testCancelReadOnlyAutocommit() { @Test public void testCancelReadOnlyAutocommitMultipleStatements() { + assumeFalse( + "Direct executor does not yet support cancelling statements", + statementExecutorType == StatementExecutorType.DIRECT_EXECUTOR); + mockSpanner.setExecuteStreamingSqlExecutionTime( SimulatedExecutionTime.ofMinimumAndRandomTime(EXECUTION_TIME_SLOW_STATEMENT, 0)); @@ -675,6 +695,10 @@ public void testCancelReadOnlyAutocommitMultipleStatements() { @Test public void testCancelReadOnlyTransactional() { + assumeFalse( + "Direct executor does not yet support cancelling statements", + statementExecutorType == StatementExecutorType.DIRECT_EXECUTOR); + mockSpanner.setExecuteStreamingSqlExecutionTime( SimulatedExecutionTime.ofMinimumAndRandomTime(EXECUTION_TIME_SLOW_STATEMENT, 0)); @@ -700,6 +724,10 @@ public void testCancelReadOnlyTransactional() { @Test public void testCancelReadOnlyTransactionalMultipleStatements() { + assumeFalse( + "Direct executor does not yet support cancelling statements", + statementExecutorType == StatementExecutorType.DIRECT_EXECUTOR); + mockSpanner.setExecuteStreamingSqlExecutionTime( SimulatedExecutionTime.ofMinimumAndRandomTime(EXECUTION_TIME_SLOW_STATEMENT, 0)); @@ -737,6 +765,10 @@ public void testCancelReadOnlyTransactionalMultipleStatements() { @Test public void testCancelReadWriteAutocommit() { + assumeFalse( + "Direct executor does not yet support cancelling statements", + statementExecutorType == StatementExecutorType.DIRECT_EXECUTOR); + mockSpanner.setExecuteStreamingSqlExecutionTime( SimulatedExecutionTime.ofMinimumAndRandomTime(EXECUTION_TIME_SLOW_STATEMENT, 0)); @@ -761,6 +793,10 @@ public void testCancelReadWriteAutocommit() { @Test public void testCancelReadWriteAutocommitMultipleStatements() { + assumeFalse( + "Direct executor does not yet support cancelling statements", + statementExecutorType == StatementExecutorType.DIRECT_EXECUTOR); + mockSpanner.setExecuteStreamingSqlExecutionTime( SimulatedExecutionTime.ofMinimumAndRandomTime(EXECUTION_TIME_SLOW_STATEMENT, 0)); @@ -792,6 +828,10 @@ public void testCancelReadWriteAutocommitMultipleStatements() { @Test public void testCancelReadWriteAutocommitSlowUpdate() { + assumeFalse( + "Direct executor does not yet support cancelling statements", + statementExecutorType == StatementExecutorType.DIRECT_EXECUTOR); + mockSpanner.setExecuteSqlExecutionTime( SimulatedExecutionTime.ofMinimumAndRandomTime(EXECUTION_TIME_SLOW_STATEMENT, 0)); @@ -815,6 +855,10 @@ public void testCancelReadWriteAutocommitSlowUpdate() { @Test public void testCancelReadWriteAutocommitSlowCommit() { + assumeFalse( + "Direct executor does not yet support cancelling statements", + statementExecutorType == StatementExecutorType.DIRECT_EXECUTOR); + mockSpanner.setCommitExecutionTime( SimulatedExecutionTime.ofMinimumAndRandomTime(EXECUTION_TIME_SLOW_STATEMENT, 0)); @@ -838,6 +882,10 @@ public void testCancelReadWriteAutocommitSlowCommit() { @Test public void testCancelReadWriteTransactional() { + assumeFalse( + "Direct executor does not yet support cancelling statements", + statementExecutorType == StatementExecutorType.DIRECT_EXECUTOR); + mockSpanner.setExecuteStreamingSqlExecutionTime( SimulatedExecutionTime.ofMinimumAndRandomTime(EXECUTION_TIME_SLOW_STATEMENT, 0)); @@ -862,6 +910,10 @@ public void testCancelReadWriteTransactional() { @Test public void testCancelReadWriteTransactionalMultipleStatements() { + assumeFalse( + "Direct executor does not yet support cancelling statements", + statementExecutorType == StatementExecutorType.DIRECT_EXECUTOR); + mockSpanner.setExecuteStreamingSqlExecutionTime( SimulatedExecutionTime.ofMinimumAndRandomTime(EXECUTION_TIME_SLOW_STATEMENT, 0)); @@ -928,6 +980,10 @@ static void addMockDdlOperations(int count, boolean done) { @Test public void testCancelDdlBatch() { + assumeFalse( + "Direct executor does not yet support cancelling statements", + statementExecutorType == StatementExecutorType.DIRECT_EXECUTOR); + addSlowMockDdlOperation(); try (Connection connection = createConnection()) { @@ -951,6 +1007,10 @@ public void testCancelDdlBatch() { @Test public void testCancelDdlAutocommit() { + assumeFalse( + "Direct executor does not yet support cancelling statements", + statementExecutorType == StatementExecutorType.DIRECT_EXECUTOR); + addSlowMockDdlOperation(); try (Connection connection = createConnection()) { From 331942f51b11660b9de9c8fe8aacd6f60ac254b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Olav=20L=C3=B8ite?= Date: Tue, 10 Dec 2024 10:29:15 +0100 Subject: [PATCH 12/14] feat: support 'set local' for retry_aborts_internally (#3532) Adds support for `set local retry_aborts_internally=true|false` in the Connection API. This change also adds the parsing infrastructure that is needed to support `set local` for all connection variables. Support for this will be added to other connection variables in follow-up pull requests. --- .../ClientSideStatementSetExecutor.java | 62 +- .../spanner/connection/ConnectionImpl.java | 6 +- .../ConnectionStatementExecutor.java | 2 +- .../ConnectionStatementExecutorImpl.java | 5 +- .../connection/ClientSideStatements.json | 11 +- .../connection/PG_ClientSideStatements.json | 19 +- .../ConnectionStateMockServerTest.java | 63 + .../connection/ClientSideStatementsTest.sql | 674 +++++ .../ConnectionImplGeneratedSqlScriptTest.sql | 224 +- .../postgresql/ClientSideStatementsTest.sql | 2696 +++++++++++++++++ .../ConnectionImplGeneratedSqlScriptTest.sql | 224 +- 11 files changed, 3740 insertions(+), 246 deletions(-) diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ClientSideStatementSetExecutor.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ClientSideStatementSetExecutor.java index 413905116ff..38c7c364106 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ClientSideStatementSetExecutor.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ClientSideStatementSetExecutor.java @@ -16,13 +16,18 @@ package com.google.cloud.spanner.connection; +import com.google.cloud.Tuple; import com.google.cloud.spanner.ErrorCode; import com.google.cloud.spanner.SpannerExceptionFactory; import com.google.cloud.spanner.connection.AbstractStatementParser.ParsedStatement; import com.google.cloud.spanner.connection.ClientSideStatementImpl.CompileException; import com.google.common.base.Preconditions; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; +import com.google.common.util.concurrent.UncheckedExecutionException; import java.lang.reflect.Constructor; import java.lang.reflect.Method; +import java.util.concurrent.ExecutionException; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -31,8 +36,10 @@ * AUTOCOMMIT=TRUE. */ class ClientSideStatementSetExecutor implements ClientSideStatementExecutor { + private final Cache> cache; private final ClientSideStatementImpl statement; private final Method method; + private final boolean supportsLocal; private final ClientSideStatementValueConverter converter; private final Pattern allowedValuesPattern; @@ -46,12 +53,18 @@ class ClientSideStatementSetExecutor implements ClientSideStatementExecutor { @SuppressWarnings("unchecked") ClientSideStatementSetExecutor(ClientSideStatementImpl statement) throws CompileException { Preconditions.checkNotNull(statement.getSetStatement()); + this.cache = + CacheBuilder.newBuilder() + .maximumSize(25) + // Set the concurrency level to 1, as we don't expect many concurrent updates. + .concurrencyLevel(1) + .build(); try { this.statement = statement; this.allowedValuesPattern = Pattern.compile( String.format( - "(?is)\\A\\s*set\\s+%s\\s*%s\\s*%s\\s*\\z", + "(?is)\\A\\s*set\\s+((?:local|session)\\s+)?%s\\s*%s\\s*%s\\s*\\z", statement.getSetStatement().getPropertyName(), statement.getSetStatement().getSeparator(), statement.getSetStatement().getAllowedValues())); @@ -64,9 +77,21 @@ class ClientSideStatementSetExecutor implements ClientSideStatementExecutor { Constructor> constructor = converterClass.getConstructor(String.class); this.converter = constructor.newInstance(statement.getSetStatement().getAllowedValues()); - this.method = - ConnectionStatementExecutor.class.getDeclaredMethod( - statement.getMethodName(), converter.getParameterClass()); + Method method; + boolean supportsLocal; + try { + method = + ConnectionStatementExecutor.class.getDeclaredMethod( + statement.getMethodName(), converter.getParameterClass()); + supportsLocal = false; + } catch (NoSuchMethodException ignore) { + method = + ConnectionStatementExecutor.class.getDeclaredMethod( + statement.getMethodName(), converter.getParameterClass(), Boolean.class); + supportsLocal = true; + } + this.method = method; + this.supportsLocal = supportsLocal; } catch (Exception e) { throw new CompileException(e, statement); } @@ -75,17 +100,29 @@ class ClientSideStatementSetExecutor implements ClientSideStatementExecutor { @Override public StatementResult execute(ConnectionStatementExecutor connection, ParsedStatement statement) throws Exception { - return (StatementResult) - method.invoke(connection, getParameterValue(statement.getSqlWithoutComments())); + Tuple value; + try { + value = + this.cache.get( + statement.getSqlWithoutComments(), + () -> getParameterValue(statement.getSqlWithoutComments())); + } catch (ExecutionException | UncheckedExecutionException executionException) { + throw SpannerExceptionFactory.asSpannerException(executionException.getCause()); + } + if (this.supportsLocal) { + return (StatementResult) method.invoke(connection, value.x(), value.y()); + } + return (StatementResult) method.invoke(connection, value.x()); } - T getParameterValue(String sql) { + Tuple getParameterValue(String sql) { Matcher matcher = allowedValuesPattern.matcher(sql); - if (matcher.find() && matcher.groupCount() >= 1) { - String value = matcher.group(1); + if (matcher.find() && matcher.groupCount() >= 2) { + boolean local = matcher.group(1) != null && "local".equalsIgnoreCase(matcher.group(1).trim()); + String value = matcher.group(2); T res = converter.convert(value); if (res != null) { - return res; + return Tuple.of(res, local); } throw SpannerExceptionFactory.newSpannerException( ErrorCode.INVALID_ARGUMENT, @@ -94,8 +131,9 @@ T getParameterValue(String sql) { this.statement.getSetStatement().getPropertyName(), value)); } else { Matcher invalidMatcher = this.statement.getPattern().matcher(sql); - if (invalidMatcher.find() && invalidMatcher.groupCount() == 1) { - String invalidValue = invalidMatcher.group(1); + int valueGroup = this.supportsLocal ? 2 : 1; + if (invalidMatcher.find() && invalidMatcher.groupCount() == valueGroup) { + String invalidValue = invalidMatcher.group(valueGroup); throw SpannerExceptionFactory.newSpannerException( ErrorCode.INVALID_ARGUMENT, String.format( diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionImpl.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionImpl.java index 25ee8b39af4..9f4a43d5a2e 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionImpl.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionImpl.java @@ -942,8 +942,12 @@ public boolean isRetryAbortsInternally() { @Override public void setRetryAbortsInternally(boolean retryAbortsInternally) { + setRetryAbortsInternally(retryAbortsInternally, /* local = */ false); + } + + void setRetryAbortsInternally(boolean retryAbortsInternally, boolean local) { checkSetRetryAbortsInternallyAvailable(); - setConnectionPropertyValue(RETRY_ABORTS_INTERNALLY, retryAbortsInternally); + setConnectionPropertyValue(RETRY_ABORTS_INTERNALLY, retryAbortsInternally, local); } @Override diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionStatementExecutor.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionStatementExecutor.java index 48f79118fee..458f117242e 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionStatementExecutor.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionStatementExecutor.java @@ -44,7 +44,7 @@ interface ConnectionStatementExecutor { StatementResult statementShowReadOnly(); - StatementResult statementSetRetryAbortsInternally(Boolean retryAbortsInternally); + StatementResult statementSetRetryAbortsInternally(Boolean retryAbortsInternally, Boolean local); StatementResult statementShowRetryAbortsInternally(); diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionStatementExecutorImpl.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionStatementExecutorImpl.java index 9b28ee7503b..a321c6a5cbc 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionStatementExecutorImpl.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionStatementExecutorImpl.java @@ -181,9 +181,10 @@ public StatementResult statementShowReadOnly() { } @Override - public StatementResult statementSetRetryAbortsInternally(Boolean retryAbortsInternally) { + public StatementResult statementSetRetryAbortsInternally( + Boolean retryAbortsInternally, Boolean local) { Preconditions.checkNotNull(retryAbortsInternally); - getConnection().setRetryAbortsInternally(retryAbortsInternally); + getConnection().setRetryAbortsInternally(retryAbortsInternally, local); return noResult(SET_RETRY_ABORTS_INTERNALLY); } diff --git a/google-cloud-spanner/src/main/resources/com/google/cloud/spanner/connection/ClientSideStatements.json b/google-cloud-spanner/src/main/resources/com/google/cloud/spanner/connection/ClientSideStatements.json index 31e8d4efd1d..7998d50c2b8 100644 --- a/google-cloud-spanner/src/main/resources/com/google/cloud/spanner/connection/ClientSideStatements.json +++ b/google-cloud-spanner/src/main/resources/com/google/cloud/spanner/connection/ClientSideStatements.json @@ -355,13 +355,18 @@ } }, { - "name": "SET RETRY_ABORTS_INTERNALLY = TRUE|FALSE", + "name": "SET [LOCAL] RETRY_ABORTS_INTERNALLY = TRUE|FALSE", "executorName": "ClientSideStatementSetExecutor", "resultType": "NO_RESULT", "statementType": "SET_RETRY_ABORTS_INTERNALLY", - "regex": "(?is)\\A\\s*set\\s+retry_aborts_internally\\s*(?:=)\\s*(.*)\\z", + "regex": "(?is)\\A\\s*set\\s+(local\\s+)?retry_aborts_internally\\s*(?:=)\\s*(.*)\\z", "method": "statementSetRetryAbortsInternally", - "exampleStatements": ["set retry_aborts_internally = true", "set retry_aborts_internally = false"], + "exampleStatements": [ + "set retry_aborts_internally = true", + "set retry_aborts_internally = false", + "set local retry_aborts_internally = true", + "set local retry_aborts_internally = false" + ], "examplePrerequisiteStatements": ["set readonly = false", "set autocommit = false"], "setStatement": { "propertyName": "RETRY_ABORTS_INTERNALLY", diff --git a/google-cloud-spanner/src/main/resources/com/google/cloud/spanner/connection/PG_ClientSideStatements.json b/google-cloud-spanner/src/main/resources/com/google/cloud/spanner/connection/PG_ClientSideStatements.json index 969487142e1..1c9dea19597 100644 --- a/google-cloud-spanner/src/main/resources/com/google/cloud/spanner/connection/PG_ClientSideStatements.json +++ b/google-cloud-spanner/src/main/resources/com/google/cloud/spanner/connection/PG_ClientSideStatements.json @@ -404,13 +404,26 @@ } }, { - "name": "SET SPANNER.RETRY_ABORTS_INTERNALLY =|TO TRUE|FALSE", + "name": "SET [SESSION|LOCAL] SPANNER.RETRY_ABORTS_INTERNALLY =|TO TRUE|FALSE", "executorName": "ClientSideStatementSetExecutor", "resultType": "NO_RESULT", "statementType": "SET_RETRY_ABORTS_INTERNALLY", - "regex": "(?is)\\A\\s*set\\s+spanner\\.retry_aborts_internally(?:\\s*=\\s*|\\s+to\\s+)(.*)\\z", + "regex": "(?is)\\A\\s*set\\s+((?:session|local)\\s+)?spanner\\.retry_aborts_internally(?:\\s*=\\s*|\\s+to\\s+)(.*)\\z", "method": "statementSetRetryAbortsInternally", - "exampleStatements": ["set spanner.retry_aborts_internally = true", "set spanner.retry_aborts_internally = false", "set spanner.retry_aborts_internally to true", "set spanner.retry_aborts_internally to false"], + "exampleStatements": [ + "set spanner.retry_aborts_internally = true", + "set spanner.retry_aborts_internally = false", + "set spanner.retry_aborts_internally to true", + "set spanner.retry_aborts_internally to false", + "set local spanner.retry_aborts_internally = true", + "set local spanner.retry_aborts_internally = false", + "set local spanner.retry_aborts_internally to true", + "set local spanner.retry_aborts_internally to false", + "set session spanner.retry_aborts_internally = true", + "set session spanner.retry_aborts_internally = false", + "set session spanner.retry_aborts_internally to true", + "set session spanner.retry_aborts_internally to false" + ], "examplePrerequisiteStatements": ["set spanner.readonly = false", "set autocommit = false"], "setStatement": { "propertyName": "SPANNER.RETRY_ABORTS_INTERNALLY", diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ConnectionStateMockServerTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ConnectionStateMockServerTest.java index ea79a7132bf..4c9397a6714 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ConnectionStateMockServerTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/ConnectionStateMockServerTest.java @@ -19,10 +19,15 @@ import static com.google.cloud.spanner.connection.ConnectionProperties.CONNECTION_STATE_TYPE; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; +import static org.junit.Assume.assumeTrue; import com.google.cloud.spanner.Dialect; +import com.google.cloud.spanner.ErrorCode; import com.google.cloud.spanner.MockSpannerServiceImpl.StatementResult; +import com.google.cloud.spanner.SpannerException; +import com.google.cloud.spanner.Statement; import com.google.cloud.spanner.connection.ConnectionState.Type; import com.google.cloud.spanner.connection.ITAbstractSpannerTest.ITConnection; import org.junit.After; @@ -84,6 +89,10 @@ ITConnection createConnection(ConnectionState.Type type) { return createConnection(";" + CONNECTION_STATE_TYPE.getKey() + "=" + type.name()); } + String getPrefix() { + return dialect == Dialect.POSTGRESQL ? "SPANNER." : ""; + } + @Test public void testConnectionStateType() { try (Connection connection = createConnection()) { @@ -228,4 +237,58 @@ public void testLocalChangeIsLostAfterTransaction() { } } } + + @Test + public void testSetLocalWithSqlStatement() { + try (Connection connection = createConnection()) { + connection.setAutocommit(false); + + assertTrue(connection.isRetryAbortsInternally()); + connection.execute( + Statement.of(String.format("set local %sretry_aborts_internally=false", getPrefix()))); + assertFalse(connection.isRetryAbortsInternally()); + connection.commit(); + assertTrue(connection.isRetryAbortsInternally()); + } + } + + @Test + public void testSetSessionWithSqlStatement() { + assumeTrue("Only PostgreSQL supports the 'session' keyword", dialect == Dialect.POSTGRESQL); + + try (Connection connection = createConnection()) { + connection.setAutocommit(false); + + assertTrue(connection.isRetryAbortsInternally()); + connection.execute( + Statement.of(String.format("set session %sretry_aborts_internally=false", getPrefix()))); + assertFalse(connection.isRetryAbortsInternally()); + connection.commit(); + assertFalse(connection.isRetryAbortsInternally()); + } + } + + @Test + public void testSetLocalInvalidValue() { + try (Connection connection = createConnection()) { + connection.setAutocommit(false); + + assertTrue(connection.isRetryAbortsInternally()); + SpannerException exception = + assertThrows( + SpannerException.class, + () -> + connection.execute( + Statement.of( + String.format("set local %sretry_aborts_internally=foo", getPrefix())))); + assertEquals(ErrorCode.INVALID_ARGUMENT, exception.getErrorCode()); + assertTrue( + exception.getMessage(), + exception + .getMessage() + .endsWith( + String.format("Unknown value for %sRETRY_ABORTS_INTERNALLY: foo", getPrefix()))); + assertTrue(connection.isRetryAbortsInternally()); + } + } } diff --git a/google-cloud-spanner/src/test/resources/com/google/cloud/spanner/connection/ClientSideStatementsTest.sql b/google-cloud-spanner/src/test/resources/com/google/cloud/spanner/connection/ClientSideStatementsTest.sql index 552e75f1097..181f30987d0 100644 --- a/google-cloud-spanner/src/test/resources/com/google/cloud/spanner/connection/ClientSideStatementsTest.sql +++ b/google-cloud-spanner/src/test/resources/com/google/cloud/spanner/connection/ClientSideStatementsTest.sql @@ -9895,6 +9895,680 @@ set autocommit = false; @EXPECT EXCEPTION INVALID_ARGUMENT set retry_aborts_internally =/-false; NEW_CONNECTION; +set readonly = false; +set autocommit = false; +set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +SET LOCAL RETRY_ABORTS_INTERNALLY = TRUE; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; + set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; + set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; + + + +set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +set local retry_aborts_internally = true ; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +set local retry_aborts_internally = true ; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +set local retry_aborts_internally = true + +; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +set +local +retry_aborts_internally += +true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +foo set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = true bar; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +%set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = true%; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =%true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +_set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = true_; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =_true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +&set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = true&; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =&true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +$set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = true$; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =$true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +@set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = true@; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =@true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +!set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = true!; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =!true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +*set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = true*; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =*true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +(set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = true(; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =(true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +)set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = true); +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =)true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = true-; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =-true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT ++set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = true+; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =+true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-#set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = true-#; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =-#true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = true/; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =/true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +\set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = true\; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =\true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +?set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = true?; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =?true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-/set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = true-/; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =-/true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/#set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = true/#; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =/#true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/-set local retry_aborts_internally = true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = true/-; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =/-true; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +SET LOCAL RETRY_ABORTS_INTERNALLY = FALSE; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; + set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; + set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; + + + +set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +set local retry_aborts_internally = false ; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +set local retry_aborts_internally = false ; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +set local retry_aborts_internally = false + +; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +set +local +retry_aborts_internally += +false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +foo set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = false bar; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +%set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = false%; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =%false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +_set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = false_; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =_false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +&set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = false&; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =&false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +$set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = false$; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =$false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +@set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = false@; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =@false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +!set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = false!; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =!false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +*set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = false*; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =*false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +(set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = false(; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =(false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +)set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = false); +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =)false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = false-; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =-false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT ++set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = false+; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =+false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-#set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = false-#; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =-#false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = false/; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =/false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +\set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = false\; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =\false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +?set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = false?; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =?false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-/set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = false-/; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =-/false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/#set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = false/#; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =/#false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/-set local retry_aborts_internally = false; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally = false/-; +NEW_CONNECTION; +set readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local retry_aborts_internally =/-false; +NEW_CONNECTION; set autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; NEW_CONNECTION; SET AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; diff --git a/google-cloud-spanner/src/test/resources/com/google/cloud/spanner/connection/ConnectionImplGeneratedSqlScriptTest.sql b/google-cloud-spanner/src/test/resources/com/google/cloud/spanner/connection/ConnectionImplGeneratedSqlScriptTest.sql index 5985ba92479..5dcf6577d5b 100644 --- a/google-cloud-spanner/src/test/resources/com/google/cloud/spanner/connection/ConnectionImplGeneratedSqlScriptTest.sql +++ b/google-cloud-spanner/src/test/resources/com/google/cloud/spanner/connection/ConnectionImplGeneratedSqlScriptTest.sql @@ -160,15 +160,15 @@ NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=FALSE; COMMIT; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:10.066000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:10.066000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:24.280000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:24.280000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=FALSE; COMMIT; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:10.066000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:24.280000000Z'; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=FALSE; @@ -510,15 +510,15 @@ NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=FALSE; SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:10.187000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:10.187000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:24.405000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:24.405000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=FALSE; SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:10.187000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:24.405000000Z'; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=FALSE; @@ -950,8 +950,8 @@ BEGIN TRANSACTION; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; ROLLBACK; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:10.294000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:10.294000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:24.518000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:24.518000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=TRUE; @@ -961,7 +961,7 @@ BEGIN TRANSACTION; SELECT 1 AS TEST; ROLLBACK; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:10.294000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:24.518000000Z'; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=FALSE; @@ -1462,8 +1462,8 @@ BEGIN TRANSACTION; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; COMMIT; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:10.413000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:10.413000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:24.636000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:24.636000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=TRUE; @@ -1473,7 +1473,7 @@ BEGIN TRANSACTION; SELECT 1 AS TEST; COMMIT; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:10.413000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:24.636000000Z'; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=FALSE; @@ -1876,15 +1876,15 @@ NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=FALSE; BEGIN TRANSACTION; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:10.523000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:10.523000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:24.733000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:24.733000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=FALSE; BEGIN TRANSACTION; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:10.523000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:24.733000000Z'; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=FALSE; @@ -2243,14 +2243,14 @@ SET AUTOCOMMIT=FALSE; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:10.613000000Z'; +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:24.812000000Z'; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=FALSE; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:10.613000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:24.812000000Z'; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=FALSE; @@ -2600,13 +2600,13 @@ SET READONLY=TRUE; SET AUTOCOMMIT=FALSE; SELECT 1 AS TEST; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:10.705000000Z'; +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:24.901000000Z'; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=FALSE; SELECT 1 AS TEST; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:10.705000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:24.901000000Z'; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=FALSE; @@ -2910,14 +2910,14 @@ SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:10.790000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:10.790000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:24.978000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:24.978000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=FALSE; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:10.790000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:24.978000000Z'; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=FALSE; @@ -3245,15 +3245,15 @@ NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; COMMIT; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:10.890000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:10.890000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.078000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:25.078000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; COMMIT; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:10.890000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.078000000Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -3662,8 +3662,8 @@ SET AUTOCOMMIT=FALSE; START BATCH DDL; CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); RUN BATCH; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:10.965000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:10.965000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.149000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:25.149000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; @@ -3672,7 +3672,7 @@ START BATCH DDL; CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); RUN BATCH; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:10.965000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.149000000Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -4081,14 +4081,14 @@ SET AUTOCOMMIT=FALSE; START BATCH DDL; CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.043000000Z'; +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.223000000Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; START BATCH DDL; CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.043000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.223000000Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -4438,13 +4438,13 @@ SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; START BATCH DDL; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.113000000Z'; +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.284000000Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; START BATCH DDL; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.113000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.284000000Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -4877,8 +4877,8 @@ SET TRANSACTION READ ONLY; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; COMMIT; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.181000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:11.181000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.349000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:25.349000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; @@ -4888,7 +4888,7 @@ SET TRANSACTION READ ONLY; SELECT 1 AS TEST; COMMIT; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.181000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.349000000Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -5288,15 +5288,15 @@ NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; SET TRANSACTION READ ONLY; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.260000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:11.260000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.424000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:25.424000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; SET TRANSACTION READ ONLY; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.260000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.424000000Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -5641,15 +5641,15 @@ NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.330000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:11.330000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.488000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:25.488000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; SET READ_ONLY_STALENESS='EXACT_STALENESS 10s'; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.330000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.488000000Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -6088,8 +6088,8 @@ BEGIN TRANSACTION; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; ROLLBACK; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.402000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:11.402000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.558000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:25.558000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; @@ -6099,7 +6099,7 @@ BEGIN TRANSACTION; SELECT 1 AS TEST; ROLLBACK; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.402000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.558000000Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -6607,8 +6607,8 @@ BEGIN TRANSACTION; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; COMMIT; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.495000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:11.495000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.646000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:25.646000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; @@ -6618,7 +6618,7 @@ BEGIN TRANSACTION; SELECT 1 AS TEST; COMMIT; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.495000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.646000000Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -7023,15 +7023,15 @@ NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; BEGIN TRANSACTION; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.578000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:11.578000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.725000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:25.725000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; BEGIN TRANSACTION; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.578000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.725000000Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -7394,14 +7394,14 @@ SET AUTOCOMMIT=FALSE; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.654000000Z'; +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.790000000Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.654000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.790000000Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -7756,13 +7756,13 @@ SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; SELECT 1 AS TEST; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.734000000Z'; +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.868000000Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; SELECT 1 AS TEST; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.734000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.868000000Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -8075,14 +8075,14 @@ SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.805000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:11.805000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.940000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:25.940000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.805000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.940000000Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -8392,13 +8392,13 @@ SET READONLY=FALSE; SET AUTOCOMMIT=TRUE; START BATCH DDL; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.865000000Z'; +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=TRUE; START BATCH DDL; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.865000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=TRUE; @@ -8753,8 +8753,8 @@ SET READONLY=FALSE; SET AUTOCOMMIT=TRUE; BEGIN TRANSACTION; SET TRANSACTION READ ONLY; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.924000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:11.924000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.061000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.061000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; @@ -8762,7 +8762,7 @@ SET AUTOCOMMIT=TRUE; BEGIN TRANSACTION; SET TRANSACTION READ ONLY; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.924000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.061000000Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=TRUE; @@ -9200,8 +9200,8 @@ SET AUTOCOMMIT=TRUE; BEGIN TRANSACTION; UPDATE foo SET bar=1; COMMIT; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.991000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:11.991000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.128000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.128000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; @@ -9209,8 +9209,8 @@ SET AUTOCOMMIT=TRUE; BEGIN TRANSACTION; UPDATE foo SET bar=1; COMMIT; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.991000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:11.991000000Z' +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.128000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.128000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; @@ -9596,15 +9596,15 @@ NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=TRUE; BEGIN TRANSACTION; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.064000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.064000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.200000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.200000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=TRUE; BEGIN TRANSACTION; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.064000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.200000000Z'; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=TRUE; @@ -9958,15 +9958,15 @@ NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=TRUE; CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.125000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.125000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.258000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.258000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=TRUE; CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.125000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.125000000Z' +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.258000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.258000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; @@ -10329,15 +10329,15 @@ NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=TRUE; UPDATE foo SET bar=1; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.193000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.193000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.325000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.325000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=TRUE; UPDATE foo SET bar=1; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.193000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.193000000Z' +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.325000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.325000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; @@ -10730,16 +10730,16 @@ SET READONLY=FALSE; SET AUTOCOMMIT=TRUE; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.262000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.262000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.390000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.390000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=TRUE; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.262000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.262000000Z' +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.390000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.390000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; @@ -11125,15 +11125,15 @@ NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=TRUE; SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.330000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.330000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.456000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.456000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=TRUE; SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.330000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.330000000Z' +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.456000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.456000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; @@ -11466,14 +11466,14 @@ SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.396000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.396000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.538000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.538000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.396000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.396000000Z' +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.538000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.538000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=FALSE; @@ -11796,15 +11796,15 @@ NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=TRUE; SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.456000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.456000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.595000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.595000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=TRUE; SET READ_ONLY_STALENESS='MAX_STALENESS 10s'; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.456000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.456000000Z' +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.595000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.595000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=TRUE; @@ -12211,8 +12211,8 @@ SET AUTOCOMMIT=TRUE; BEGIN TRANSACTION; SELECT 1 AS TEST; COMMIT; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.519000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.519000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.658000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.658000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=TRUE; @@ -12220,8 +12220,8 @@ SET AUTOCOMMIT=TRUE; BEGIN TRANSACTION; SELECT 1 AS TEST; COMMIT; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.519000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.519000000Z' +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.658000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.658000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=TRUE; @@ -12604,15 +12604,15 @@ NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=TRUE; BEGIN TRANSACTION; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.586000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.586000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.723000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.723000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=TRUE; BEGIN TRANSACTION; @EXPECT EXCEPTION FAILED_PRECONDITION -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.586000000Z'; +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.723000000Z'; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=TRUE; @@ -12950,15 +12950,15 @@ NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=TRUE; SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.650000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.650000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.781000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.781000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=TRUE; SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.650000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.650000000Z' +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.781000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.781000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=TRUE; @@ -13305,15 +13305,15 @@ NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=TRUE; SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.715000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.715000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.844000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.844000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=TRUE; SELECT 1 AS TEST; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.715000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.715000000Z' +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.844000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.844000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=TRUE; @@ -13630,14 +13630,14 @@ SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.778000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.778000000Z' +SET READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.904000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.904000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=TRUE; SET AUTOCOMMIT=TRUE; -SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.778000000Z'; -@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.778000000Z' +SET READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.904000000Z'; +@EXPECT RESULT_SET 'READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.904000000Z' SHOW VARIABLE READ_ONLY_STALENESS; NEW_CONNECTION; SET READONLY=TRUE; diff --git a/google-cloud-spanner/src/test/resources/com/google/cloud/spanner/connection/postgresql/ClientSideStatementsTest.sql b/google-cloud-spanner/src/test/resources/com/google/cloud/spanner/connection/postgresql/ClientSideStatementsTest.sql index aea0bf4b808..54374f0ad87 100644 --- a/google-cloud-spanner/src/test/resources/com/google/cloud/spanner/connection/postgresql/ClientSideStatementsTest.sql +++ b/google-cloud-spanner/src/test/resources/com/google/cloud/spanner/connection/postgresql/ClientSideStatementsTest.sql @@ -49892,6 +49892,2702 @@ set autocommit = false; @EXPECT EXCEPTION INVALID_ARGUMENT set spanner.retry_aborts_internally to/-false; NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +SET LOCAL SPANNER.RETRY_ABORTS_INTERNALLY = TRUE; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + + + +set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally = true ; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally = true ; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally = true + +; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set +local +spanner.retry_aborts_internally += +true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +foo set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = true bar; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +%set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = true%; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =%true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +_set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = true_; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =_true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +&set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = true&; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =&true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +$set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = true$; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =$true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +@set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = true@; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =@true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +!set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = true!; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =!true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +*set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = true*; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =*true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +(set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = true(; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =(true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +)set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = true); +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =)true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = true-; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =-true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT ++set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = true+; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =+true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-#set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = true-#; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =-#true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = true/; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =/true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +\set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = true\; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =\true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +?set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = true?; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =?true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-/set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = true-/; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =-/true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/#set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = true/#; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =/#true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/-set local spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = true/-; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =/-true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +SET LOCAL SPANNER.RETRY_ABORTS_INTERNALLY = FALSE; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + + + +set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally = false ; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally = false ; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally = false + +; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set +local +spanner.retry_aborts_internally += +false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +foo set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = false bar; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +%set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = false%; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =%false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +_set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = false_; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =_false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +&set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = false&; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =&false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +$set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = false$; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =$false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +@set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = false@; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =@false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +!set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = false!; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =!false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +*set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = false*; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =*false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +(set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = false(; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =(false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +)set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = false); +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =)false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = false-; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =-false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT ++set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = false+; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =+false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-#set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = false-#; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =-#false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = false/; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =/false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +\set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = false\; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =\false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +?set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = false?; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =?false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-/set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = false-/; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =-/false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/#set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = false/#; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =/#false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/-set local spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally = false/-; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally =/-false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +SET LOCAL SPANNER.RETRY_ABORTS_INTERNALLY TO TRUE; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + + + +set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally to true ; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally to true ; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally to true + +; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set +local +spanner.retry_aborts_internally +to +true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +foo set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to true bar; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +%set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to true%; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to%true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +_set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to true_; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to_true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +&set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to true&; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to&true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +$set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to true$; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to$true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +@set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to true@; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to@true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +!set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to true!; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to!true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +*set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to true*; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to*true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +(set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to true(; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to(true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +)set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to true); +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to)true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to true-; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to-true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT ++set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to true+; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to+true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-#set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to true-#; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to-#true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to true/; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to/true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +\set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to true\; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to\true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +?set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to true?; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to?true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-/set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to true-/; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to-/true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/#set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to true/#; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to/#true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/-set local spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to true/-; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to/-true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +SET LOCAL SPANNER.RETRY_ABORTS_INTERNALLY TO FALSE; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + + + +set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally to false ; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally to false ; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally to false + +; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set +local +spanner.retry_aborts_internally +to +false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +foo set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to false bar; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +%set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to false%; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to%false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +_set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to false_; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to_false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +&set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to false&; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to&false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +$set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to false$; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to$false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +@set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to false@; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to@false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +!set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to false!; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to!false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +*set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to false*; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to*false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +(set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to false(; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to(false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +)set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to false); +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to)false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to false-; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to-false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT ++set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to false+; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to+false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-#set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to false-#; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to-#false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to false/; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to/false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +\set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to false\; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to\false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +?set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to false?; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to?false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-/set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to false-/; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to-/false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/#set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to false/#; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to/#false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/-set local spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to false/-; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set local spanner.retry_aborts_internally to/-false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +SET SESSION SPANNER.RETRY_ABORTS_INTERNALLY = TRUE; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + + + +set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally = true ; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally = true ; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally = true + +; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set +session +spanner.retry_aborts_internally += +true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +foo set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = true bar; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +%set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = true%; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =%true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +_set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = true_; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =_true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +&set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = true&; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =&true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +$set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = true$; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =$true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +@set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = true@; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =@true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +!set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = true!; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =!true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +*set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = true*; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =*true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +(set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = true(; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =(true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +)set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = true); +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =)true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = true-; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =-true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT ++set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = true+; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =+true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-#set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = true-#; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =-#true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = true/; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =/true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +\set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = true\; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =\true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +?set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = true?; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =?true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-/set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = true-/; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =-/true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/#set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = true/#; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =/#true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/-set session spanner.retry_aborts_internally = true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = true/-; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =/-true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +SET SESSION SPANNER.RETRY_ABORTS_INTERNALLY = FALSE; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + + + +set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally = false ; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally = false ; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally = false + +; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set +session +spanner.retry_aborts_internally += +false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +foo set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = false bar; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +%set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = false%; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =%false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +_set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = false_; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =_false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +&set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = false&; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =&false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +$set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = false$; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =$false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +@set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = false@; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =@false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +!set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = false!; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =!false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +*set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = false*; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =*false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +(set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = false(; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =(false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +)set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = false); +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =)false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = false-; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =-false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT ++set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = false+; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =+false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-#set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = false-#; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =-#false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = false/; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =/false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +\set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = false\; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =\false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +?set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = false?; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =?false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-/set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = false-/; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =-/false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/#set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = false/#; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =/#false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/-set session spanner.retry_aborts_internally = false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally = false/-; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally =/-false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +SET SESSION SPANNER.RETRY_ABORTS_INTERNALLY TO TRUE; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + + + +set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally to true ; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally to true ; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally to true + +; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set +session +spanner.retry_aborts_internally +to +true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +foo set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to true bar; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +%set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to true%; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to%true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +_set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to true_; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to_true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +&set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to true&; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to&true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +$set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to true$; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to$true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +@set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to true@; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to@true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +!set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to true!; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to!true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +*set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to true*; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to*true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +(set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to true(; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to(true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +)set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to true); +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to)true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to true-; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to-true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT ++set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to true+; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to+true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-#set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to true-#; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to-#true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to true/; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to/true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +\set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to true\; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to\true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +?set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to true?; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to?true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-/set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to true-/; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to-/true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/#set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to true/#; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to/#true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/-set session spanner.retry_aborts_internally to true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to true/-; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to/-true; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +SET SESSION SPANNER.RETRY_ABORTS_INTERNALLY TO FALSE; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; + + + +set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally to false ; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally to false ; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally to false + +; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +set +session +spanner.retry_aborts_internally +to +false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +foo set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to false bar; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +%set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to false%; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to%false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +_set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to false_; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to_false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +&set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to false&; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to&false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +$set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to false$; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to$false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +@set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to false@; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to@false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +!set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to false!; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to!false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +*set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to false*; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to*false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +(set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to false(; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to(false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +)set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to false); +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to)false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to false-; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to-false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT ++set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to false+; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to+false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-#set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to false-#; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to-#false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to false/; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to/false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +\set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to false\; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to\false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +?set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to false?; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to?false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +-/set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to false-/; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to-/false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/#set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to false/#; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to/#false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +/-set session spanner.retry_aborts_internally to false; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to false/-; +NEW_CONNECTION; +set spanner.readonly = false; +set autocommit = false; +@EXPECT EXCEPTION INVALID_ARGUMENT +set session spanner.retry_aborts_internally to/-false; +NEW_CONNECTION; set spanner.autocommit_dml_mode='PARTITIONED_NON_ATOMIC'; NEW_CONNECTION; SET SPANNER.AUTOCOMMIT_DML_MODE='PARTITIONED_NON_ATOMIC'; diff --git a/google-cloud-spanner/src/test/resources/com/google/cloud/spanner/connection/postgresql/ConnectionImplGeneratedSqlScriptTest.sql b/google-cloud-spanner/src/test/resources/com/google/cloud/spanner/connection/postgresql/ConnectionImplGeneratedSqlScriptTest.sql index 3db3bda388b..f5456bb55ee 100644 --- a/google-cloud-spanner/src/test/resources/com/google/cloud/spanner/connection/postgresql/ConnectionImplGeneratedSqlScriptTest.sql +++ b/google-cloud-spanner/src/test/resources/com/google/cloud/spanner/connection/postgresql/ConnectionImplGeneratedSqlScriptTest.sql @@ -160,15 +160,15 @@ NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=FALSE; COMMIT; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:10.130000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:10.130000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:24.347000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:24.347000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=FALSE; COMMIT; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:10.130000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:24.347000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=FALSE; @@ -510,15 +510,15 @@ NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=FALSE; SET SPANNER.READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:10.240000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:10.240000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:24.458000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:24.458000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=FALSE; SET SPANNER.READ_ONLY_STALENESS='EXACT_STALENESS 10s'; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:10.240000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:24.458000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=FALSE; @@ -950,8 +950,8 @@ BEGIN TRANSACTION; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; ROLLBACK; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:10.352000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:10.352000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:24.580000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:24.580000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; @@ -961,7 +961,7 @@ BEGIN TRANSACTION; SELECT 1 AS TEST; ROLLBACK; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:10.352000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:24.580000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=FALSE; @@ -1462,8 +1462,8 @@ BEGIN TRANSACTION; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; COMMIT; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:10.472000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:10.472000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:24.692000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:24.692000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; @@ -1473,7 +1473,7 @@ BEGIN TRANSACTION; SELECT 1 AS TEST; COMMIT; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:10.472000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:24.692000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=FALSE; @@ -1876,15 +1876,15 @@ NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=FALSE; BEGIN TRANSACTION; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:10.566000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:10.566000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:24.772000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:24.772000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=FALSE; BEGIN TRANSACTION; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:10.566000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:24.772000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=FALSE; @@ -2243,14 +2243,14 @@ SET AUTOCOMMIT=FALSE; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:10.661000000Z'; +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:24.857000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=FALSE; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:10.661000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:24.857000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=FALSE; @@ -2600,13 +2600,13 @@ SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=FALSE; SELECT 1 AS TEST; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:10.751000000Z'; +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:24.942000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=FALSE; SELECT 1 AS TEST; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:10.751000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:24.942000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=FALSE; @@ -2910,14 +2910,14 @@ SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=FALSE; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:10.827000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:10.827000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.018000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:25.018000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=FALSE; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:10.827000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.018000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=FALSE; @@ -3245,15 +3245,15 @@ NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; COMMIT; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:10.925000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:10.925000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.111000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:25.111000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; COMMIT; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:10.925000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.111000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -3662,8 +3662,8 @@ SET AUTOCOMMIT=FALSE; START BATCH DDL; CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); RUN BATCH; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.005000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:11.005000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.187000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:25.187000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; @@ -3672,7 +3672,7 @@ START BATCH DDL; CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); RUN BATCH; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.005000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.187000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -4081,14 +4081,14 @@ SET AUTOCOMMIT=FALSE; START BATCH DDL; CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.078000000Z'; +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.253000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; START BATCH DDL; CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.078000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.253000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -4438,13 +4438,13 @@ SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; START BATCH DDL; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.144000000Z'; +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.315000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; START BATCH DDL; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.144000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.315000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -4877,8 +4877,8 @@ SET TRANSACTION READ ONLY; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; COMMIT; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.224000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:11.224000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.390000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:25.390000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; @@ -4888,7 +4888,7 @@ SET TRANSACTION READ ONLY; SELECT 1 AS TEST; COMMIT; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.224000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.390000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -5288,15 +5288,15 @@ NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; SET TRANSACTION READ ONLY; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.296000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:11.296000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.454000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:25.454000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; SET TRANSACTION READ ONLY; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.296000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.454000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -5641,15 +5641,15 @@ NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; SET SPANNER.READ_ONLY_STALENESS='EXACT_STALENESS 10s'; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.363000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:11.363000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.519000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:25.519000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; SET SPANNER.READ_ONLY_STALENESS='EXACT_STALENESS 10s'; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.363000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.519000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -6088,8 +6088,8 @@ BEGIN TRANSACTION; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; ROLLBACK; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.444000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:11.444000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.597000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:25.597000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; @@ -6099,7 +6099,7 @@ BEGIN TRANSACTION; SELECT 1 AS TEST; ROLLBACK; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.444000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.597000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -6607,8 +6607,8 @@ BEGIN TRANSACTION; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; COMMIT; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.539000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:11.539000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.689000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:25.689000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; @@ -6618,7 +6618,7 @@ BEGIN TRANSACTION; SELECT 1 AS TEST; COMMIT; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.539000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.689000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -7023,15 +7023,15 @@ NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; BEGIN TRANSACTION; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.614000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:11.614000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.755000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:25.755000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; BEGIN TRANSACTION; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.614000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.755000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -7394,14 +7394,14 @@ SET AUTOCOMMIT=FALSE; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.693000000Z'; +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.829000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.693000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.829000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -7756,13 +7756,13 @@ SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; SELECT 1 AS TEST; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.771000000Z'; +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.906000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; SELECT 1 AS TEST; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.771000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.906000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -8075,14 +8075,14 @@ SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.836000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:11.836000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:25.970000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:25.970000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.836000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:25.970000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=FALSE; @@ -8392,13 +8392,13 @@ SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=TRUE; START BATCH DDL; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.894000000Z'; +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.028000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=TRUE; START BATCH DDL; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.894000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.028000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=TRUE; @@ -8753,8 +8753,8 @@ SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=TRUE; BEGIN TRANSACTION; SET TRANSACTION READ ONLY; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:11.953000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:11.953000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.091000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.091000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; @@ -8762,7 +8762,7 @@ SET AUTOCOMMIT=TRUE; BEGIN TRANSACTION; SET TRANSACTION READ ONLY; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:11.953000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.091000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=TRUE; @@ -9200,8 +9200,8 @@ SET AUTOCOMMIT=TRUE; BEGIN TRANSACTION; UPDATE foo SET bar=1; COMMIT; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.028000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.028000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.165000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.165000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; @@ -9209,8 +9209,8 @@ SET AUTOCOMMIT=TRUE; BEGIN TRANSACTION; UPDATE foo SET bar=1; COMMIT; -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.028000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.028000000Z' +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.165000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.165000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; @@ -9596,15 +9596,15 @@ NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=TRUE; BEGIN TRANSACTION; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.093000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.093000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.228000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.228000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=TRUE; BEGIN TRANSACTION; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.093000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.228000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=TRUE; @@ -9958,15 +9958,15 @@ NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=TRUE; CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.159000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.159000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.292000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.292000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=TRUE; CREATE TABLE foo (id INT64 NOT NULL, name STRING(100)) PRIMARY KEY (id); -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.159000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.159000000Z' +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.292000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.292000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; @@ -10329,15 +10329,15 @@ NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=TRUE; UPDATE foo SET bar=1; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.227000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.227000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.357000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.357000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=TRUE; UPDATE foo SET bar=1; -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.227000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.227000000Z' +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.357000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.357000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; @@ -10730,16 +10730,16 @@ SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=TRUE; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.296000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.296000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.423000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.423000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=TRUE; @EXPECT RESULT_SET 'TEST',1 SELECT 1 AS TEST; -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.296000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.296000000Z' +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.423000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.423000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; @@ -11125,15 +11125,15 @@ NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=TRUE; SELECT 1 AS TEST; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.365000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.365000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.492000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.492000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=TRUE; SELECT 1 AS TEST; -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.365000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.365000000Z' +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.492000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.492000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; @@ -11466,14 +11466,14 @@ SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=TRUE; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.427000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.427000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.567000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.567000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; SET AUTOCOMMIT=TRUE; -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.427000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.427000000Z' +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.567000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.567000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=FALSE; @@ -11796,15 +11796,15 @@ NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=TRUE; SET SPANNER.READ_ONLY_STALENESS='MAX_STALENESS 10s'; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.485000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.485000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.626000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.626000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=TRUE; SET SPANNER.READ_ONLY_STALENESS='MAX_STALENESS 10s'; -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.485000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.485000000Z' +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.626000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.626000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; @@ -12211,8 +12211,8 @@ SET AUTOCOMMIT=TRUE; BEGIN TRANSACTION; SELECT 1 AS TEST; COMMIT; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.555000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.555000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.692000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.692000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; @@ -12220,8 +12220,8 @@ SET AUTOCOMMIT=TRUE; BEGIN TRANSACTION; SELECT 1 AS TEST; COMMIT; -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.555000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.555000000Z' +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.692000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.692000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; @@ -12604,15 +12604,15 @@ NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=TRUE; BEGIN TRANSACTION; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.615000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.615000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.751000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.751000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=TRUE; BEGIN TRANSACTION; @EXPECT EXCEPTION FAILED_PRECONDITION -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.615000000Z'; +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.751000000Z'; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=TRUE; @@ -12950,15 +12950,15 @@ NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=TRUE; SELECT 1 AS TEST; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.682000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.682000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.812000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.812000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=TRUE; SELECT 1 AS TEST; -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.682000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.682000000Z' +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.812000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.812000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; @@ -13305,15 +13305,15 @@ NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=TRUE; SELECT 1 AS TEST; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.747000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.747000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.875000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.875000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=TRUE; SELECT 1 AS TEST; -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.747000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.747000000Z' +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.875000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.875000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; @@ -13630,14 +13630,14 @@ SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=TRUE; -SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-11-25T10:49:12.807000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-11-25T10:49:12.807000000Z' +SET SPANNER.READ_ONLY_STALENESS='READ_TIMESTAMP 2024-12-07T16:05:26.931000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','READ_TIMESTAMP 2024-12-07T16:05:26.931000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; SET AUTOCOMMIT=TRUE; -SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-11-25T10:49:12.807000000Z'; -@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-11-25T10:49:12.807000000Z' +SET SPANNER.READ_ONLY_STALENESS='MIN_READ_TIMESTAMP 2024-12-07T16:05:26.931000000Z'; +@EXPECT RESULT_SET 'SPANNER.READ_ONLY_STALENESS','MIN_READ_TIMESTAMP 2024-12-07T16:05:26.931000000Z' SHOW VARIABLE SPANNER.READ_ONLY_STALENESS; NEW_CONNECTION; SET SPANNER.READONLY=TRUE; From 216f53e4cbc0150078ece7785da33b342a6ab082 Mon Sep 17 00:00:00 2001 From: Pratick Chokhani Date: Wed, 11 Dec 2024 15:27:55 +0530 Subject: [PATCH 13/14] feat: add opt-in for using multiplexed sessions for blind writes (#3540) * feat(spanner): Releasing Multiplexed session for blind write. * fix(spanner): Added exception for `setUseMultiplexedSessionBlindWrite` in Clirr check. Removing this is safe as it's not used by customers. * fix(spanner): Fixed unit test for multiplexed session. --- .../clirr-ignored-differences.xml | 5 ++++ .../executor/spanner/CloudClientExecutor.java | 2 -- .../spanner/SessionPoolOptionsHelper.java | 8 ------ .../cloud/spanner/SessionPoolOptions.java | 25 +------------------ ...edSessionDatabaseClientMockServerTest.java | 1 - .../RetryOnInvalidatedSessionTest.java | 3 +++ 6 files changed, 9 insertions(+), 35 deletions(-) diff --git a/google-cloud-spanner-executor/clirr-ignored-differences.xml b/google-cloud-spanner-executor/clirr-ignored-differences.xml index 9d3c127bcc9..11e9890f1d9 100644 --- a/google-cloud-spanner-executor/clirr-ignored-differences.xml +++ b/google-cloud-spanner-executor/clirr-ignored-differences.xml @@ -7,4 +7,9 @@ CloudExecutorImpl(boolean) CloudExecutorImpl(boolean, double) + + 7002 + com/google/cloud/spanner/SessionPoolOptionsHelper + com.google.cloud.spanner.SessionPoolOptions$Builder setUseMultiplexedSessionBlindWrite(com.google.cloud.spanner.SessionPoolOptions$Builder, boolean) + diff --git a/google-cloud-spanner-executor/src/main/java/com/google/cloud/executor/spanner/CloudClientExecutor.java b/google-cloud-spanner-executor/src/main/java/com/google/cloud/executor/spanner/CloudClientExecutor.java index c82b6306eb8..d3f5712646a 100644 --- a/google-cloud-spanner-executor/src/main/java/com/google/cloud/executor/spanner/CloudClientExecutor.java +++ b/google-cloud-spanner-executor/src/main/java/com/google/cloud/executor/spanner/CloudClientExecutor.java @@ -830,8 +830,6 @@ private synchronized Spanner getClient(long timeoutSeconds, boolean useMultiplex com.google.cloud.spanner.SessionPoolOptions.Builder poolOptionsBuilder = com.google.cloud.spanner.SessionPoolOptions.newBuilder(); SessionPoolOptionsHelper.setUseMultiplexedSession(poolOptionsBuilder, useMultiplexedSession); - SessionPoolOptionsHelper.setUseMultiplexedSessionBlindWrite( - poolOptionsBuilder, useMultiplexedSession); SessionPoolOptionsHelper.setUseMultiplexedSessionForRW( poolOptionsBuilder, useMultiplexedSession); LOGGER.log( diff --git a/google-cloud-spanner-executor/src/main/java/com/google/cloud/spanner/SessionPoolOptionsHelper.java b/google-cloud-spanner-executor/src/main/java/com/google/cloud/spanner/SessionPoolOptionsHelper.java index f19cb8f4a2f..9dd8ac29563 100644 --- a/google-cloud-spanner-executor/src/main/java/com/google/cloud/spanner/SessionPoolOptionsHelper.java +++ b/google-cloud-spanner-executor/src/main/java/com/google/cloud/spanner/SessionPoolOptionsHelper.java @@ -31,14 +31,6 @@ public static SessionPoolOptions.Builder setUseMultiplexedSession( return sessionPoolOptionsBuilder.setUseMultiplexedSession(useMultiplexedSession); } - // TODO: Remove when multiplexed session for blind write is released. - public static SessionPoolOptions.Builder setUseMultiplexedSessionBlindWrite( - SessionPoolOptions.Builder sessionPoolOptionsBuilder, - boolean useMultiplexedSessionBlindWrite) { - return sessionPoolOptionsBuilder.setUseMultiplexedSessionBlindWrite( - useMultiplexedSessionBlindWrite); - } - // TODO: Remove when multiplexed session for read write is released. public static SessionPoolOptions.Builder setUseMultiplexedSessionForRW( SessionPoolOptions.Builder sessionPoolOptionsBuilder, boolean useMultiplexedSessionForRW) { diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java index a691f14817f..36a4e5fe208 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java @@ -77,12 +77,6 @@ public class SessionPoolOptions { private final boolean useMultiplexedSession; - /** - * Controls whether multiplexed session is enabled for blind write or not. This is only used for - * systest soak. TODO: Remove when multiplexed session for blind write is released. - */ - private final boolean useMultiplexedSessionBlindWrite; - private final boolean useMultiplexedSessionForRW; private final boolean useMultiplexedSessionForPartitionedOps; @@ -122,7 +116,6 @@ private SessionPoolOptions(Builder builder) { (useMultiplexedSessionFromEnvVariable != null) ? useMultiplexedSessionFromEnvVariable : builder.useMultiplexedSession; - this.useMultiplexedSessionBlindWrite = builder.useMultiplexedSessionBlindWrite; // useMultiplexedSessionForRW priority => Environment var > private setter > client default Boolean useMultiplexedSessionForRWFromEnvVariable = getUseMultiplexedSessionForRWFromEnvVariable(); @@ -205,7 +198,6 @@ public int hashCode() { this.inactiveTransactionRemovalOptions, this.poolMaintainerClock, this.useMultiplexedSession, - this.useMultiplexedSessionBlindWrite, this.useMultiplexedSessionForRW, this.multiplexedSessionMaintenanceDuration); } @@ -349,7 +341,7 @@ public boolean getUseMultiplexedSession() { @VisibleForTesting @InternalApi protected boolean getUseMultiplexedSessionBlindWrite() { - return getUseMultiplexedSession() && useMultiplexedSessionBlindWrite; + return getUseMultiplexedSession(); } @VisibleForTesting @@ -601,9 +593,6 @@ public static class Builder { // Set useMultiplexedSession to true to make multiplexed session the default. private boolean useMultiplexedSession = false; - // TODO: Remove when multiplexed session for blind write is released. - private boolean useMultiplexedSessionBlindWrite = false; - // This field controls the default behavior of session management for RW operations in Java // client. // Set useMultiplexedSessionForRW to true to make multiplexed session for RW operations the @@ -657,7 +646,6 @@ private Builder(SessionPoolOptions options) { this.randomizePositionQPSThreshold = options.randomizePositionQPSThreshold; this.inactiveTransactionRemovalOptions = options.inactiveTransactionRemovalOptions; this.useMultiplexedSession = options.useMultiplexedSession; - this.useMultiplexedSessionBlindWrite = options.useMultiplexedSessionBlindWrite; this.useMultiplexedSessionForRW = options.useMultiplexedSessionForRW; this.useMultiplexedSessionPartitionedOps = options.useMultiplexedSessionForPartitionedOps; this.multiplexedSessionMaintenanceDuration = options.multiplexedSessionMaintenanceDuration; @@ -857,17 +845,6 @@ Builder setUseMultiplexedSession(boolean useMultiplexedSession) { return this; } - /** - * This method enables multiplexed sessions for blind writes. This method will be removed in the - * future when multiplexed sessions has been made the default for all operations. - */ - @InternalApi - @VisibleForTesting - Builder setUseMultiplexedSessionBlindWrite(boolean useMultiplexedSessionBlindWrite) { - this.useMultiplexedSessionBlindWrite = useMultiplexedSessionBlindWrite; - return this; - } - /** * Sets whether the client should use multiplexed session for R/W operations or not. This method * is intentionally package-private and intended for internal use. diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClientMockServerTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClientMockServerTest.java index 3121b868b83..c808bbe1110 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClientMockServerTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionDatabaseClientMockServerTest.java @@ -93,7 +93,6 @@ public void createSpannerInstance() { .setSessionPoolOption( SessionPoolOptions.newBuilder() .setUseMultiplexedSession(true) - .setUseMultiplexedSessionBlindWrite(true) .setUseMultiplexedSessionForRW(true) .setUseMultiplexedSessionPartitionedOps(true) // Set the maintainer to loop once every 1ms diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/RetryOnInvalidatedSessionTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/RetryOnInvalidatedSessionTest.java index 3032a1cae40..a6c3f9fa7c5 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/RetryOnInvalidatedSessionTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/RetryOnInvalidatedSessionTest.java @@ -1288,6 +1288,9 @@ public void write() throws InterruptedException { @Test public void writeAtLeastOnce() throws InterruptedException { + assumeFalse( + "Multiplexed session do not throw a SessionNotFound errors. ", + spanner.getOptions().getSessionPoolOptions().getUseMultiplexedSession()); assertThrowsSessionNotFoundIfShouldFail( () -> client.writeAtLeastOnce( From 2a962a76da857b836ea971d4fe0b2a77c9056ce6 Mon Sep 17 00:00:00 2001 From: Sakthivel Subramanian <179120858+sakthivelmanii@users.noreply.github.com> Date: Wed, 11 Dec 2024 15:50:37 +0530 Subject: [PATCH 14/14] ci(spanner): clean up unused kokoro configurations (#3542) * ci(spanner): clean up unused kokoro configurations * chore: generate libraries at Tue Dec 10 09:54:10 UTC 2024 --------- Co-authored-by: cloud-java-bot --- .kokoro/continuous/java8.cfg | 12 ------- .kokoro/nightly/java7.cfg | 7 ---- .kokoro/nightly/java8-win.cfg | 3 -- .kokoro/presubmit/clirr.cfg | 13 ------- .kokoro/presubmit/integration-cloud-devel.cfg | 22 ------------ .kokoro/presubmit/java11-samples.cfg | 34 ------------------- .kokoro/presubmit/java11.cfg | 7 ---- .kokoro/presubmit/java7.cfg | 7 ---- .kokoro/presubmit/java8-osx.cfg | 3 -- .kokoro/presubmit/java8-samples.cfg | 34 ------------------- .kokoro/presubmit/java8-win.cfg | 3 -- .kokoro/presubmit/java8.cfg | 12 ------- .kokoro/presubmit/linkage-monitor.cfg | 12 ------- .kokoro/presubmit/lint.cfg | 13 ------- .kokoro/presubmit/samples.cfg | 33 ------------------ owlbot.py | 4 --- synth.metadata | 25 -------------- 17 files changed, 244 deletions(-) delete mode 100644 .kokoro/continuous/java8.cfg delete mode 100644 .kokoro/nightly/java7.cfg delete mode 100644 .kokoro/nightly/java8-win.cfg delete mode 100644 .kokoro/presubmit/clirr.cfg delete mode 100644 .kokoro/presubmit/integration-cloud-devel.cfg delete mode 100644 .kokoro/presubmit/java11-samples.cfg delete mode 100644 .kokoro/presubmit/java11.cfg delete mode 100644 .kokoro/presubmit/java7.cfg delete mode 100644 .kokoro/presubmit/java8-osx.cfg delete mode 100644 .kokoro/presubmit/java8-samples.cfg delete mode 100644 .kokoro/presubmit/java8-win.cfg delete mode 100644 .kokoro/presubmit/java8.cfg delete mode 100644 .kokoro/presubmit/linkage-monitor.cfg delete mode 100644 .kokoro/presubmit/lint.cfg delete mode 100644 .kokoro/presubmit/samples.cfg diff --git a/.kokoro/continuous/java8.cfg b/.kokoro/continuous/java8.cfg deleted file mode 100644 index 495cc7bacd6..00000000000 --- a/.kokoro/continuous/java8.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "REPORT_COVERAGE" - value: "true" -} diff --git a/.kokoro/nightly/java7.cfg b/.kokoro/nightly/java7.cfg deleted file mode 100644 index cb24f44eea3..00000000000 --- a/.kokoro/nightly/java7.cfg +++ /dev/null @@ -1,7 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java7" -} diff --git a/.kokoro/nightly/java8-win.cfg b/.kokoro/nightly/java8-win.cfg deleted file mode 100644 index b219b38ad4a..00000000000 --- a/.kokoro/nightly/java8-win.cfg +++ /dev/null @@ -1,3 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -build_file: "java-spanner/.kokoro/build.bat" diff --git a/.kokoro/presubmit/clirr.cfg b/.kokoro/presubmit/clirr.cfg deleted file mode 100644 index ec572442e2e..00000000000 --- a/.kokoro/presubmit/clirr.cfg +++ /dev/null @@ -1,13 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. - -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "JOB_TYPE" - value: "clirr" -} \ No newline at end of file diff --git a/.kokoro/presubmit/integration-cloud-devel.cfg b/.kokoro/presubmit/integration-cloud-devel.cfg deleted file mode 100644 index 94b698199e1..00000000000 --- a/.kokoro/presubmit/integration-cloud-devel.cfg +++ /dev/null @@ -1,22 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "JOB_TYPE" - value: "integration-cloud-devel" -} - -env_vars: { - key: "GOOGLE_APPLICATION_CREDENTIALS" - value: "secret_manager/java-client-testing" -} - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "java-client-testing" -} diff --git a/.kokoro/presubmit/java11-samples.cfg b/.kokoro/presubmit/java11-samples.cfg deleted file mode 100644 index 2812301e787..00000000000 --- a/.kokoro/presubmit/java11-samples.cfg +++ /dev/null @@ -1,34 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java11" -} - -env_vars: { - key: "JOB_TYPE" - value: "samples" -} - -# TODO: remove this after we've migrated all tests and scripts -env_vars: { - key: "GCLOUD_PROJECT" - value: "gcloud-devel" -} - -env_vars: { - key: "GOOGLE_CLOUD_PROJECT" - value: "gcloud-devel" -} - -env_vars: { - key: "GOOGLE_APPLICATION_CREDENTIALS" - value: "secret_manager/java-it-service-account" -} - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "java-it-service-account" -} - diff --git a/.kokoro/presubmit/java11.cfg b/.kokoro/presubmit/java11.cfg deleted file mode 100644 index 709f2b4c73d..00000000000 --- a/.kokoro/presubmit/java11.cfg +++ /dev/null @@ -1,7 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java11" -} diff --git a/.kokoro/presubmit/java7.cfg b/.kokoro/presubmit/java7.cfg deleted file mode 100644 index cb24f44eea3..00000000000 --- a/.kokoro/presubmit/java7.cfg +++ /dev/null @@ -1,7 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java7" -} diff --git a/.kokoro/presubmit/java8-osx.cfg b/.kokoro/presubmit/java8-osx.cfg deleted file mode 100644 index 63f547222f5..00000000000 --- a/.kokoro/presubmit/java8-osx.cfg +++ /dev/null @@ -1,3 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -build_file: "java-spanner/.kokoro/build.sh" diff --git a/.kokoro/presubmit/java8-samples.cfg b/.kokoro/presubmit/java8-samples.cfg deleted file mode 100644 index 49a231b9f2a..00000000000 --- a/.kokoro/presubmit/java8-samples.cfg +++ /dev/null @@ -1,34 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "JOB_TYPE" - value: "samples" -} - -# TODO: remove this after we've migrated all tests and scripts -env_vars: { - key: "GCLOUD_PROJECT" - value: "gcloud-devel" -} - -env_vars: { - key: "GOOGLE_CLOUD_PROJECT" - value: "gcloud-devel" -} - -env_vars: { - key: "GOOGLE_APPLICATION_CREDENTIALS" - value: "secret_manager/java-it-service-account" -} - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "java-it-service-account" -} - diff --git a/.kokoro/presubmit/java8-win.cfg b/.kokoro/presubmit/java8-win.cfg deleted file mode 100644 index b219b38ad4a..00000000000 --- a/.kokoro/presubmit/java8-win.cfg +++ /dev/null @@ -1,3 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -build_file: "java-spanner/.kokoro/build.bat" diff --git a/.kokoro/presubmit/java8.cfg b/.kokoro/presubmit/java8.cfg deleted file mode 100644 index 495cc7bacd6..00000000000 --- a/.kokoro/presubmit/java8.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "REPORT_COVERAGE" - value: "true" -} diff --git a/.kokoro/presubmit/linkage-monitor.cfg b/.kokoro/presubmit/linkage-monitor.cfg deleted file mode 100644 index 083448f9f80..00000000000 --- a/.kokoro/presubmit/linkage-monitor.cfg +++ /dev/null @@ -1,12 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "TRAMPOLINE_BUILD_FILE" - value: "github/java-spanner/.kokoro/linkage-monitor.sh" -} \ No newline at end of file diff --git a/.kokoro/presubmit/lint.cfg b/.kokoro/presubmit/lint.cfg deleted file mode 100644 index 6d323c8ae76..00000000000 --- a/.kokoro/presubmit/lint.cfg +++ /dev/null @@ -1,13 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. - -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "JOB_TYPE" - value: "lint" -} \ No newline at end of file diff --git a/.kokoro/presubmit/samples.cfg b/.kokoro/presubmit/samples.cfg deleted file mode 100644 index 724216504ef..00000000000 --- a/.kokoro/presubmit/samples.cfg +++ /dev/null @@ -1,33 +0,0 @@ -# Format: //devtools/kokoro/config/proto/build.proto - -# Configure the docker image for kokoro-trampoline. -env_vars: { - key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-kokoro-resources/java8" -} - -env_vars: { - key: "JOB_TYPE" - value: "samples" -} - -# TODO: remove this after we've migrated all tests and scripts -env_vars: { - key: "GCLOUD_PROJECT" - value: "gcloud-devel" -} - -env_vars: { - key: "GOOGLE_CLOUD_PROJECT" - value: "gcloud-devel" -} - -env_vars: { - key: "GOOGLE_APPLICATION_CREDENTIALS" - value: "secret_manager/java-it-service-account" -} - -env_vars: { - key: "SECRET_MANAGER_KEYS" - value: "java-it-service-account" -} diff --git a/owlbot.py b/owlbot.py index bc9b537f818..5765d1df17f 100644 --- a/owlbot.py +++ b/owlbot.py @@ -31,12 +31,8 @@ ".kokoro/nightly/samples.cfg", ".kokoro/build.bat", ".kokoro/presubmit/common.cfg", - ".kokoro/presubmit/java8-samples.cfg", - ".kokoro/presubmit/java11-samples.cfg", - ".kokoro/presubmit/samples.cfg", ".kokoro/presubmit/graalvm-native.cfg", ".kokoro/presubmit/graalvm-native-17.cfg", - ".kokoro/release/common.cfg", "samples/install-without-bom/pom.xml", "samples/snapshot/pom.xml", "samples/snippets/pom.xml", diff --git a/synth.metadata b/synth.metadata index 9622106469d..9f19ee9c447 100644 --- a/synth.metadata +++ b/synth.metadata @@ -68,41 +68,16 @@ ".kokoro/coerce_logs.sh", ".kokoro/common.cfg", ".kokoro/common.sh", - ".kokoro/continuous/java8.cfg", ".kokoro/dependencies.sh", ".kokoro/nightly/integration.cfg", ".kokoro/nightly/java11.cfg", - ".kokoro/nightly/java7.cfg", ".kokoro/nightly/java8-osx.cfg", - ".kokoro/nightly/java8-win.cfg", ".kokoro/nightly/java8.cfg", ".kokoro/populate-secrets.sh", - ".kokoro/presubmit/clirr.cfg", ".kokoro/presubmit/dependencies.cfg", ".kokoro/presubmit/graalvm-native.cfg", ".kokoro/presubmit/integration.cfg", ".kokoro/presubmit/java11.cfg", - ".kokoro/presubmit/java7.cfg", - ".kokoro/presubmit/java8-osx.cfg", - ".kokoro/presubmit/java8-win.cfg", - ".kokoro/presubmit/java8.cfg", - ".kokoro/presubmit/linkage-monitor.cfg", - ".kokoro/presubmit/lint.cfg", - ".kokoro/release/bump_snapshot.cfg", - ".kokoro/release/common.cfg", - ".kokoro/release/common.sh", - ".kokoro/release/drop.cfg", - ".kokoro/release/drop.sh", - ".kokoro/release/promote.cfg", - ".kokoro/release/promote.sh", - ".kokoro/release/publish_javadoc.cfg", - ".kokoro/release/publish_javadoc.sh", - ".kokoro/release/publish_javadoc11.cfg", - ".kokoro/release/publish_javadoc11.sh", - ".kokoro/release/snapshot.cfg", - ".kokoro/release/snapshot.sh", - ".kokoro/release/stage.cfg", - ".kokoro/release/stage.sh", ".kokoro/trampoline.sh", "CODE_OF_CONDUCT.md", "CONTRIBUTING.md",