You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/06/23 10:08:18 UTC

[GitHub] [beam] nielm commented on a change in pull request #12011: [BEAM-9269] Set Spanner commit deadline using GRPC api not interceptor.

nielm commented on a change in pull request #12011:
URL: https://github.com/apache/beam/pull/12011#discussion_r444112445



##########
File path: sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/spanner/SpannerAccessor.java
##########
@@ -63,23 +65,19 @@ static SpannerAccessor create(SpannerConfig spannerConfig) {
     ValueProvider<Duration> commitDeadline = spannerConfig.getCommitDeadline();
     if (commitDeadline != null && commitDeadline.get().getMillis() > 0) {
 
-      // In Spanner API version 1.21 or above, we can set the deadline / total Timeout on an API
-      // call using the following code:
-      //
-      // UnaryCallSettings.Builder commitSettings =
-      // builder.getSpannerStubSettingsBuilder().commitSettings();
-      // RetrySettings.Builder commitRetrySettings = commitSettings.getRetrySettings().toBuilder()
-      // commitSettings.setRetrySettings(
-      //     commitRetrySettings.setTotalTimeout(
-      //         Duration.ofMillis(getCommitDeadlineMillis().get()))
-      //     .build());
-      //
-      // However, at time of this commit, the Spanner API is at only at v1.6.0, where the only
-      // method to set a deadline is with GRPC Interceptors, so we have to use that...
-      SpannerInterceptorProvider interceptorProvider =
-          SpannerInterceptorProvider.createDefault()
-              .with(new CommitDeadlineSettingInterceptor(commitDeadline.get()));
-      builder.setInterceptorProvider(interceptorProvider);
+      // Set the GRPC deadline on the Commit API call.
+      UnaryCallSettings.Builder commitSettings =
+          builder.getSpannerStubSettingsBuilder().commitSettings();
+      RetrySettings.Builder commitRetrySettings = commitSettings.getRetrySettings().toBuilder();
+      commitSettings.setRetrySettings(
+          commitRetrySettings

Review comment:
       It can be done, but it does it silently in the background. This mechanism allows us to have a  counter for the number of timeouts which are useful for diagnosing slowness...




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org