Skip to content
Permalink
Browse files
fix: partitionedDml stub was not closed (#213)
The PartitionedDML stub was not closed when Spanner was closed.
In addition, Spanner did not wait for the channels to actually close,
causing some test cases to (sometimes) log a warning that the channel
had not been closed.
  • Loading branch information
olavloite committed May 19, 2020
1 parent 5fa82b9 commit a2d9a33fa31f7467fc2bfbef5a29c4b3f5aea7c8
Showing with 18 additions and 0 deletions.
  1. +18 −0 google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java
@@ -191,6 +191,12 @@ private synchronized void shutdown() {
executor.shutdown();
}
}

private void awaitTermination() throws InterruptedException {
for (ScheduledExecutorService executor : executors) {
executor.awaitTermination(10L, TimeUnit.SECONDS);
}
}
}

private static final PathTemplate PROJECT_NAME_TEMPLATE =
@@ -1230,10 +1236,22 @@ GrpcCallContext newCallContext(@Nullable Map<Option, ?> options, String resource
public void shutdown() {
this.rpcIsClosed = true;
this.spannerStub.close();
this.partitionedDmlStub.close();
this.instanceAdminStub.close();
this.databaseAdminStub.close();
this.spannerWatchdog.shutdown();
this.executorProvider.shutdown();

try {
this.spannerStub.awaitTermination(10L, TimeUnit.SECONDS);
this.partitionedDmlStub.awaitTermination(10L, TimeUnit.SECONDS);
this.instanceAdminStub.awaitTermination(10L, TimeUnit.SECONDS);
this.databaseAdminStub.awaitTermination(10L, TimeUnit.SECONDS);
this.spannerWatchdog.awaitTermination(10L, TimeUnit.SECONDS);
this.executorProvider.awaitTermination();
} catch (InterruptedException e) {
throw SpannerExceptionFactory.propagateInterrupt(e);
}
}

@Override

0 comments on commit a2d9a33

Please sign in to comment.