Chi-Hsuan Huang created RATIS-2830:
--------------------------------------

             Summary: Leader keeps yielding to an unreachable higher-priority 
follower and rejects writes
                 Key: RATIS-2830
                 URL: https://issues.apache.org/jira/browse/RATIS-2830
             Project: Ratis
          Issue Type: Bug
          Components: Leader
    Affects Versions: 3.3.1
            Reporter: Chi-Hsuan Huang


h3. Problem

In Ozone (HDDS-13972), the higher-priority peer of a group was restarted and 
caught up. It was then stopped again before it took back leadership.

The leader keeps transferring leadership to the stopped peer. Each attempt 
fails with {{Connection refused}}, and a new one starts shortly after it times 
out. While a transfer is pending, client writes fail with 
{{LeaderSteppingDownException}}.

{code:java}
13:01:12,173 Closing XceiverServerRatis(9964bafd)   <- higher-priority follower 
stopped
13:01:13,371 e4feb29b@group-BA798D1583A8: start transferring leadership to 
9964bafd
13:01:13,371 e4feb29b@group-BA798D1583A8: Failed to startLeaderElection for 
9964bafd ... Connection refused
13:01:14,211 Failed to send request ... LeaderSteppingDownException: 
e4feb29b@group-BA798D1583A8 is stepping down
13:01:14,571 e4feb29b@group-BA798D1583A8: start transferring leadership to 
9964bafd
13:01:15,771 e4feb29b@group-BA798D1583A8: start transferring leadership to 
9964bafd
...
{code}

h3. Root cause

{{LeaderStateImpl.checkPeersForYieldingLeader()}} only checks priority and 
{{matchIndex}}. With no new writes, a stopped follower still looks up-to-date, 
so it is picked again on every check.

{{TransferLeadership.start(LogAppender)}} already notes that a transfer blocks 
client requests, and bounds each attempt by the min RPC timeout. Nothing bounds 
the repeated attempts to a peer that is down.

{{RaftClientImpl.handleLeaderException()}} only retries {{NotLeaderException}} 
and {{LeaderNotReadyException}}, so clients get {{LeaderSteppingDownException}} 
right away.

Checked on 3.3.1 and master (2668464c64).

h3. Impact

In a local repro on 3.3.1 with a 1s min RPC timeout, the loop ran for about 30 
seconds. Writes were rejected for a few seconds, and up to about 15 seconds in 
one run.

RATIS-1770 noted that rejecting requests while yielding may make the service 
unavailable, so it only transfers to an up-to-date peer. A peer that is 
up-to-date but down seems not covered. RATIS-2311 adds an {{appliedIndex}} 
check, but a down peer's last reported value may still pass it.

h3. Possible fix

Skip followers whose {{getLastRpcResponseTime()}} is too old, similar to 
{{checkLeadership()}}. Backing off after a timed-out yield to the same peer 
could also work.




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to