[ 
https://issues.apache.org/jira/browse/RATIS-2171?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17894869#comment-17894869
 ] 

Tsz-wo Sze commented on RATIS-2171:
-----------------------------------

[~jianghuazhu], you are right that it is better to call setLogEntry(..) before 
completing logIndexFuture.  Thanks for filing this!

> 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
>            Assignee: JiangHua Zhu
>            Priority: Major
>
> 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