JiangHua Zhu created RATIS-2171:
-----------------------------------

             Summary: Safer initialization of TransactionContext#logIndexFuture
                 Key: RATIS-2171
                 URL: https://issues.apache.org/jira/browse/RATIS-2171
             Project: Ratis
          Issue Type: Improvement
          Components: server
    Affects Versions: 3.0.1
            Reporter: JiangHua Zhu


In TransactionContextImpl(), logIndexFuture is initialized after setLogEntry(), 
which is very reasonable. However, in initLogEntry(), the assignment of 
logIndexFuture is arranged before setLogEntry(), which seems to be a flaw.
TransactionContextImpl():
{code:java}
  TransactionContextImpl(RaftPeerRole serverRole, StateMachine stateMachine, 
LogEntryProto logEntry) {
    this(serverRole, null, stateMachine, logEntry.getStateMachineLogEntry());
    setLogEntry(logEntry);
    this.logIndexFuture.complete(logEntry.getIndex());
  }
{code}

initLogEntry():
{code:java}
   ......
    logIndexFuture.complete(index);
    return setLogEntry(LogProtoUtils.toLogEntryProto(stateMachineLogEntry, 
term, index));
    ......
{code}





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

Reply via email to