Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: add keepalives to GRPC channel (#11)
This patch adds keepalives to the GRPC channel every 2 minutes. By
default, there are no keepalives to the GRPC channel. While running
dataflow import jobs, issues have been observed with the spanner
commit calls that run more than 10 minutes. Adding keepalives to
the GRPC channel solves these issues.
  • Loading branch information
allenpradeep authored and olavloite committed Jan 14, 2020
1 parent 1112357 commit 428a4a6
Showing 1 changed file with 5 additions and 0 deletions.
Expand Up @@ -168,6 +168,7 @@ private synchronized void shutdown() {
"com.google.cloud.spanner.watchdogPeriodSeconds";
private static final int DEFAULT_TIMEOUT_SECONDS = 30 * 60;
private static final int DEFAULT_PERIOD_SECONDS = 10;
private static final int GRPC_KEEPALIVE_SECONDS = 2 * 60;

private final ManagedInstantiatingExecutorProvider executorProvider;
private boolean rpcIsClosed;
Expand Down Expand Up @@ -242,6 +243,10 @@ public GapicSpannerRpc(final SpannerOptions options) {
.setPoolSize(options.getNumChannels())
.setExecutorProvider(executorProvider)

// Set a keepalive time of 120 seconds to help long running
// commit GRPC calls succeed
.setKeepAliveTime(Duration.ofSeconds(GRPC_KEEPALIVE_SECONDS))

// Then check if SpannerOptions provides an InterceptorProvider. Create a default
// SpannerInterceptorProvider if none is provided
.setInterceptorProvider(
Expand Down

0 comments on commit 428a4a6

Please sign in to comment.