[ 
https://issues.apache.org/jira/browse/RATIS-2055?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Duong updated RATIS-2055:
-------------------------
    Description: 
RATIS-2019 changes the logic of `LeaderState.isReady`. Before, isReady itself 
performs the logic to check if the leader state is ready. After the change, the 
logic is moved to `LeaderState.checkReady` and `isReady` now only reads the 
result.

This change impacts client applications that rely on `isReady` check. For 
example, Ozone's SCMStateMachine [listens to notifyTermIndexUpdated 
|https://github.com/apache/ozone/blob/5ff79613e546a09f23b2c3bae61d62fb757eaf70/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMStateMachine.java#L359]
 and checks if the leader state is ready. However, because the 
`leader.checkReady` is called after the `notifyTermIndexUpdated`, 
SCMStateMachine never sees leader ready state in the intercepted 
`notifyTermIndexUpdated` events.
{code:java|title=RaftServerImpl.applyLogToStateMachine}
CompletableFuture<Message> 
applyLogToStateMachine(ReferenceCountedObject<LogEntryProto> nextRef)
    throws RaftLogIOException {
  LogEntryProto next = nextRef.get();
  if (!next.hasStateMachineLogEntry()) {
    stateMachine.event().notifyTermIndexUpdated(next.getTerm(), 
next.getIndex());
  }

  if (next.hasConfigurationEntry()) {
    // the reply should have already been set. only need to record
    // the new conf in the metadata file and notify the StateMachine.
    state.writeRaftConfiguration(next);
    stateMachine.event().notifyConfigurationChanged(next.getTerm(), 
next.getIndex(), next.getConfigurationEntry());
    role.getLeaderState().ifPresent(leader -> leader.checkReady(next)); 
....{code}
 

  was:
RATIS-2019 changes the logic of `LeaderState.isReady`. Before, isReady itself 
performs the logic to check if the leader state is ready. After the change, the 
logic is moved to `LeaderState.checkReady` and `isReady` now only reads the 
result.

This change impacts client applications that rely on `isReady` check. For 
example, Ozone's SCMStateMachine [listens to notifyTermIndexUpdated 
|https://github.com/apache/ozone/blob/5ff79613e546a09f23b2c3bae61d62fb757eaf70/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMStateMachine.java#L359]
 and checks if the leader state is ready. However, because the 
`leader.checkReady` is called after the `notifyTermIndexUpdated`, 
SCMStateMachine never sees leader ready state in the intercepted 
`notifyTermIndexUpdated` events.
{code:java|title=RaftServerImpl.applyLogToStateMachine}
CompletableFuture<Message> 
applyLogToStateMachine(ReferenceCountedObject<LogEntryProto> nextRef)
    throws RaftLogIOException {
  LogEntryProto next = nextRef.get();
  if (!next.hasStateMachineLogEntry()) {
    stateMachine.event().notifyTermIndexUpdated(next.getTerm(), 
next.getIndex());
  }

  if (next.hasConfigurationEntry()) {
    // the reply should have already been set. only need to record
    // the new conf in the metadata file and notify the StateMachine.
    state.writeRaftConfiguration(next);
    stateMachine.event().notifyConfigurationChanged(next.getTerm(), 
next.getIndex(), next.getConfigurationEntry());
    role.getLeaderState().ifPresent(leader -> leader.checkReady(next)); {code}
 


> Changed logic of LeaderState.isReady impacts application
> --------------------------------------------------------
>
>                 Key: RATIS-2055
>                 URL: https://issues.apache.org/jira/browse/RATIS-2055
>             Project: Ratis
>          Issue Type: Bug
>            Reporter: Duong
>            Priority: Major
>
> RATIS-2019 changes the logic of `LeaderState.isReady`. Before, isReady itself 
> performs the logic to check if the leader state is ready. After the change, 
> the logic is moved to `LeaderState.checkReady` and `isReady` now only reads 
> the result.
> This change impacts client applications that rely on `isReady` check. For 
> example, Ozone's SCMStateMachine [listens to notifyTermIndexUpdated 
> |https://github.com/apache/ozone/blob/5ff79613e546a09f23b2c3bae61d62fb757eaf70/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMStateMachine.java#L359]
>  and checks if the leader state is ready. However, because the 
> `leader.checkReady` is called after the `notifyTermIndexUpdated`, 
> SCMStateMachine never sees leader ready state in the intercepted 
> `notifyTermIndexUpdated` events.
> {code:java|title=RaftServerImpl.applyLogToStateMachine}
> CompletableFuture<Message> 
> applyLogToStateMachine(ReferenceCountedObject<LogEntryProto> nextRef)
>     throws RaftLogIOException {
>   LogEntryProto next = nextRef.get();
>   if (!next.hasStateMachineLogEntry()) {
>     stateMachine.event().notifyTermIndexUpdated(next.getTerm(), 
> next.getIndex());
>   }
>   if (next.hasConfigurationEntry()) {
>     // the reply should have already been set. only need to record
>     // the new conf in the metadata file and notify the StateMachine.
>     state.writeRaftConfiguration(next);
>     stateMachine.event().notifyConfigurationChanged(next.getTerm(), 
> next.getIndex(), next.getConfigurationEntry());
>     role.getLeaderState().ifPresent(leader -> leader.checkReady(next)); 
> ....{code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to