yandrey321 opened a new pull request, #1665:
URL: https://github.com/apache/ratis/pull/1665
## What changes were proposed in this pull request?
**Problem.** `GrpcUtil.shutdownManagedChannel` has hard-coded timeouts. It
calls `shutdown()` and waits up to 3 s,
then, if the channel is still running, calls `shutdownNow()` and waits up to
2 s more. A graceful shutdown finishes
only once the server has ended the client's calls. If the server doesn't end
them, closing a `RaftClient` waits the
full 3 s for each of its channels, and no setting can shorten that.
Apache Ozone keeps one `RaftClient` per pipeline in each client process
(HDDS-15255). On a 12-datanode cluster,
MapReduce clients took up to 54 s to exit, 3 s for each channel that timed
out. Closing clients in parallel brings that
down to one grace period, still at least 3 s. A client that is shutting down
has already given up on its pending
replies, and `shutdownNow()` cancels the calls anyway, so the wait buys it
nothing.
**Change.**
- Two client properties in `GrpcConfigKeys.Client`. The defaults are today's
values:
- `raft.grpc.client.channel.shutdown.graceful.timeout` (default `3s`). `0`
skips the graceful shutdown.
- `raft.grpc.client.channel.shutdown.forceful.timeout` (default `2s`).
- A new overload, `GrpcUtil.shutdownManagedChannel(channel, gracefulTimeout,
forcefulTimeout)`. The one-argument
method calls it with the defaults, so its other callers
(`GrpcServerProtocolClient`, `GrpcStubPool`) are unchanged.
- `GrpcClientProtocolClient` reads both properties and uses them for its
client and admin channels.
The server side (`GrpcServerProtocolClient`, which handles
leader-to-follower channels) is left as it is; this change
is only for clients. With the default values, behaviour is unchanged.
Generated-by: Claude Code (Claude Opus 5.5)
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/RATIS-2775
## How was this patch tested?
- **New `TestGrpcChannelShutdown`.** It uses an in-JVM gRPC server whose
bidi-streaming calls never end, so a graceful
shutdown has to wait for its timeout:
- `testGracefulTimeout`: with a 500 ms graceful timeout and an open call,
the shutdown returns after the 500 ms
graceful wait and before the default 3 s, and the channel is terminated.
- `testZeroGracefulTimeoutShutsDownNow`: with a graceful timeout of 0, it
returns in under 1 s.
- `testRaftClientUsesConfiguredTimeouts`: the server also implements
`RaftClientProtocolService/ordered` and never
replies. A `RaftClient` configured with a 500 ms graceful timeout sends
a request to it and is closed. The close
takes between 500 ms and 2.5 s.
- `testConfigKeys`: the defaults are 3 s and 2 s, and values that are set
are read back.
- **Existing tests:** the whole `org.apache.ratis.grpc` test package, 318
tests, all passing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]