Skip to content

Commit d67a75f

Browse files
authored
fix: close SpannerPool at shutdown (#734)
The server did not close the Spanner pool when it was gracefully shut down. This caused gRPC channels to remain open when the server was shut down, which again could cause applications to shut down more slowly, as they would wait for the threads that managed those channels to shut down first.
1 parent 2dd6a95 commit d67a75f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/main/java/com/google/cloud/spanner/pgadapter/ProxyServer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.google.cloud.spanner.ErrorCode;
2020
import com.google.cloud.spanner.SpannerException;
2121
import com.google.cloud.spanner.SpannerExceptionFactory;
22+
import com.google.cloud.spanner.connection.SpannerPool;
2223
import com.google.cloud.spanner.pgadapter.ConnectionHandler.QueryMode;
2324
import com.google.cloud.spanner.pgadapter.metadata.OptionsMetadata;
2425
import com.google.cloud.spanner.pgadapter.metadata.OptionsMetadata.TextFormat;
@@ -203,6 +204,10 @@ protected void doStop() {
203204
for (ConnectionHandler handler : getConnectionHandlers()) {
204205
handler.terminate();
205206
}
207+
try {
208+
SpannerPool.closeSpannerPool();
209+
} catch (Throwable ignore) {
210+
}
206211
notifyStopped();
207212
}
208213

0 commit comments

Comments
 (0)