Skip to content
Permalink
Browse files
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 428a4a6d3c9e1536a80f1fa9f76f36fe1062a104
Showing with 5 additions and 0 deletions.
  1. +5 −0 google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java
@@ -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;
@@ -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(

0 comments on commit 428a4a6

Please sign in to comment.