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

Glen Geng resolved HDDS-4059.
-----------------------------
    Resolution: Fixed

> SCMStateMachine::applyTransaction() should not invoke 
> TransactionContext.getClientRequest()
> -------------------------------------------------------------------------------------------
>
>                 Key: HDDS-4059
>                 URL: https://issues.apache.org/jira/browse/HDDS-4059
>             Project: Hadoop Distributed Data Store
>          Issue Type: Sub-task
>          Components: SCM
>            Reporter: Glen Geng
>            Assignee: Glen Geng
>            Priority: Major
>              Labels: pull-request-available
>
> applyTransaction should not call trx.getClientRequest(), since client request 
> will not be replicated from leader to follower, follower will not be able to 
> update its state machine.
> {code:java}
> SCMStateMachine
>   applyTransaction()
>     final SCMRatisRequest request = SCMRatisRequest.decode(
>         trx.getClientRequest().getMessage());{code}
>  
> Instead, we should call trx.getStateMachineLogEntry()
> {code:java}
> SCMStateMachine
>   applyTransaction()
>     final SCMRatisRequest request = SCMRatisRequest.decode(
>         Message.valueOf(trx.getStateMachineLogEntry().getLogData()));{code}
>  
> content of client request will be injected to StateMachineEntryProto at 
> leader,
> {code:java}
> static StateMachineLogEntryProto toStateMachineLogEntryProto(
>     RaftClientRequest request, ByteString logData, ByteString 
> stateMachineData) {
>   if (logData == null) {
>     logData = request.getMessage().getContent();
>   }
>   return toStateMachineLogEntryProto(request.getClientId(), 
> request.getCallId(), logData, stateMachineData);
> }
> {code}
>  
> and extracted from log entry at follower.
> {code:java}
> /**
>  * Construct a {@link TransactionContext} from a {@link LogEntryProto}.
>  * Used by followers for applying committed entries to the state machine.
>  * @param logEntry the log entry to be applied
>  */
> public TransactionContextImpl(RaftPeerRole serverRole, StateMachine 
> stateMachine, LogEntryProto logEntry) {
>   this(serverRole, stateMachine);
>   this.logEntry = logEntry;
>   this.smLogEntryProto = logEntry.getStateMachineLogEntry();
> }
> {code}
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to