EventStore / EventStoreDB-Client-Java

Official Asynchronous Java 8+ Client Library for EventStoreDB 20.6+
https://eventstore.com
Apache License 2.0
63 stars 19 forks source link

Improvement: Properly shutdown channel of gossip client. #185

Closed dpasek-senacor closed 1 year ago

dpasek-senacor commented 2 years ago

The GossipClient used for cluster discovery create a gRPC ManagedChannel which is not shutdown after usage. This causes error logs by the gRPC library when the GossipClient is garbage collected.

09:43:22,843 |- ERROR in io.grpc.internal.ManagedChannelOrphanWrapper - *~*~*~ Channel ManagedChannelImpl{logId=32, target=localhost:2113} was not shutdown properly!!! ~*~*~*
    Make sure to call shutdown()/shutdownNow() and wait until awaitTermination() returns true. -| java.lang.RuntimeException: ManagedChannel allocation site
    at io.grpc.internal.ManagedChannelOrphanWrapper$ManagedChannelReference.<init>(ManagedChannelOrphanWrapper.java:93)
    at io.grpc.internal.ManagedChannelOrphanWrapper.<init>(ManagedChannelOrphanWrapper.java:53)
    at io.grpc.internal.ManagedChannelOrphanWrapper.<init>(ManagedChannelOrphanWrapper.java:44)
    at io.grpc.internal.ManagedChannelImplBuilder.build(ManagedChannelImplBuilder.java:630)
    at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:297)
    at com.eventstore.dbclient.GrpcClient.createChannel(GrpcClient.java:322)
    at com.eventstore.dbclient.SingleNodeClient.doConnect(SingleNodeClient.java:21)
    at com.eventstore.dbclient.GrpcClient.discover(GrpcClient.java:158)
    at com.eventstore.dbclient.GrpcClient.handleMsg(GrpcClient.java:207)
    at com.eventstore.dbclient.GrpcClient.messageLoop(GrpcClient.java:259)
    at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1736)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)

See also: https://github.com/EventStore/EventStoreDB-Client-Java/issues/163