[
https://issues.apache.org/jira/browse/HDDS-17329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18154757#comment-18154757
]
Stephen O'Donnell commented on HDDS-17329:
------------------------------------------
I analysed this problem a bit more with Claude - copying the output below.
Its proposal is to fix it with basically a one liner, but I don't understand
much about the Ratis interaction to judge this solution. It also suggests a
better fix would be in ratis, letting us pass the remaining deadline in.
Quoting Claude:
I'd keep HDDS-17329 at Major, at the low end. The JIRA's numbers are right, but
it only adds latency during a failure: once Ratis gives up, Ozone fails over to
another pipeline exactly as it should, so there's no risk to data or
correctness.
I checked the description against the Ozone client and the Ratis 3.3.1 source.
Is the arithmetic right? Yes, and the 70s check effectively never ends a write
that is only timing out.
- Ratis checks the 70s write.timeout only after an attempt fails
(RequestTypeDependentRetryPolicy.handleAttemptFailure, which measures from when
the request was created). Each attempt has its own fixed 60s gRPC deadline
(GrpcClientProtocolClient:380). Ratis's async send(Message) has no way to set a
per-call timeout.
- For TimeoutIOException, Ozone uses exponential backoff with max.retries=2.
a. The first timeout lands at about 60s. That's under 70s, so Ratis retries
after a 1–3s backoff.
b. On a timeout, Ratis switches to a random other peer
(RaftClientImpl.handleIOException).
c. The second timeout lands at about 121–123s, and the attempt cap ends it.
- So with timeouts alone, the 70s check never stops anything; the attempt cap
does. Mixed failures are worse. For example, a quick NotLeaderException can
trigger a retry at 69s that then waits a full 60s on a hung leader. The worst
case is about 70 + 7.5 (multilinear backoff) + 60 ≈ 137s.
- After that, RaftRetryFailureException reaches KeyOutputStream, which excludes
the pipeline, allocates a new block and retries straight away. That part works
correctly.
Why it's Major but no higher
- What triggers it: a leader that stays connected but doesn't respond. Examples
are a disk stall, a long GC pause, a pipeline that has lost quorum, or a
half-open TCP connection. A datanode that is cleanly dead fails fast through
connection errors and isn't affected.
- Impact: every writer on that pipeline blocks about twice as long (up to ~2
minutes) before failing over. Each one also holds its buffered data and a slot
in the client's outstanding-request window. Operators who set write.timeout to
bound write latency get up to write.timeout + rpc.request.timeout instead.
- Why not higher: it only happens on the failure path, the extra time is
bounded, and there's no data risk. Many callers, S3 clients for example,
already give up before 70s, so for them the difference is small.
Proposed fix
Recommended: bound the caller's wait in XceiverClientRatis.sendRequestAsync.
The JIRA's first suggestion, limiting each Ratis attempt to the remaining time,
isn't possible through Ratis's async API. What Ozone can do is limit how long
the caller waits:
// constructor
this.writeTimeout =
configuration.getObject(RatisClientConfig.class).getWriteRequestTimeout();
// sendRequestAsync, write branch
// Ratis checks the write timeout only when an attempt fails, so a write could
otherwise take up to the write timeout
// plus a full RPC request timeout. copy() leaves the Ratis future, and its
ordered sliding window, untouched.
return
getClient().async().send(message).copy().orTimeout(writeTimeout.toMillis(),
TimeUnit.MILLISECONDS);
- Why copy() matters: Ratis stops retrying once its own reply future is done
(OrderedAsync:193). But if Ozone completes Ratis's future itself, Ratis's
ordered sliding window never fails the rest of the window, so other requests on
the same shared client could each hang until their own timeouts. Timing out a
copy avoids that.
- The cost: the attempt already in flight, and possibly a second one, keeps
running in the background for up to about 53s and holds one of the 32
outstanding-request slots. That's acceptable because the stream has already
excluded the pipeline.
- How the failure is handled: orTimeout fails with
java.util.concurrent.TimeoutException. That class is already in
HddsClientUtils.EXCEPTION_LIST, so KeyOutputStream excludes the pipeline and
retries without sleeping, the same as RaftRetryFailureException.
- The one difference is that the client isn't invalidated, so the unused
client for the excluded pipeline stays cached until it's evicted.
- Adding TimeoutException to checkForRetryFailure would invalidate it too.
I'd leave that out, because watch and flush timeouts also produce
TimeoutException.
- Small change: one field and one changed line. hdds-client compiles for Java
17, so copy() and orTimeout are available.
- Test: add a unit test in TestXceiverClientRatis with a stubbed RaftClient
whose async().send() never completes. Set write.timeout=1s and check that
sendCommandAsync fails with TimeoutException within about 1s.
Alternatives
- Configuration only: lower the default
hdds.ratis.raft.client.rpc.request.timeout to at most half the write timeout,
for example 30s. A pure-timeout write would then end at about 62s, under 70s.
The mixed-failure worst case is still about 100s, though, and a shorter attempt
timeout risks spurious timeouts, and so more pipeline exclusions, under heavy
load. I wouldn't change this default on its own.
- Fix it in Ratis: treat the request-type timeout as a deadline, so each
attempt gets min(rpcTimeout, remaining). That's the cleanest design, but it
needs a RATIS JIRA and a Ratis upgrade. It's worth filing alongside the Ozone
fix, not instead of it.
> Ratis client write can take about 2 minutes although
> hdds.ratis.client.request.write.timeout is 70s
> ---------------------------------------------------------------------------------------------------
>
> Key: HDDS-17329
> URL: https://issues.apache.org/jira/browse/HDDS-17329
> Project: Apache Ozone
> Issue Type: Bug
> Components: Ozone Client
> Reporter: Siyao Meng
> Priority: Major
>
> The Ratis client retry policy ({{RequestTypeDependentRetryPolicyCreator}})
> checks {{hdds.ratis.client.request.write.timeout}} (70s) only when an attempt
> fails, and each attempt is bounded by
> {{hdds.ratis.raft.client.rpc.request.timeout}} (60s). On a timeout it retries
> with exponential backoff (base 1s, max 5s). So if the leader does not answer,
> the first attempt fails at 60s, which is within 70s; the client sleeps 1 to
> 3s and tries again, and the second attempt fails at about 121 to 123s (by
> calculation). In general a write can take up to about the write timeout plus
> the request timeout.
> Proposed fix: bound each request by the remaining write timeout in
> {{XceiverClientRatis.sendRequestAsync}}, or keep the default RPC request
> timeout at most half of the write timeout.
> Related: HDDS-15444
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]