Skip to content

Commit

Permalink
fix: partitionedDml stub was not closed (#213)
Browse files Browse the repository at this point in the history
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 a2d9a33
Showing 1 changed file with 18 additions and 0 deletions.
Expand Up @@ -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 =
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a2d9a33

Please sign in to comment.