EventStore / EventStoreDB-Client-Java

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

Regression: Use graceful shutdown of channel in case of reconnect #183

Closed dpasek-senacor closed 2 years ago

dpasek-senacor commented 2 years ago

With one of the last PRs we have introduce a proper shutdown of ManagedChannels in case of reconnection attempts after connection loss or a NotLeaderException. This shutdown did not use the graceful shutdown() of the channel but the forced shutdown of the channel using shutdownNow(). This might interfere with running gRPC operations which are not properly aborted. Tests have shown that these running gRPC operations just do not complete aka a client is waiting indefinitely for the result.

To avoid this the channel should be closed using the same approach as closing the channel on shutdown: applying first a graceful shutdown and then if necessary perform a forced shutdown after this grace period.

This also improves code reuse and reduces complexity in the GrpcClient.