Details
-
Sub-task
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
Description
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.
SCMStateMachine
applyTransaction()
final SCMRatisRequest request = SCMRatisRequest.decode(
trx.getClientRequest().getMessage());
Instead, we should call trx.getStateMachineLogEntry()
SCMStateMachine
applyTransaction()
final SCMRatisRequest request = SCMRatisRequest.decode(
Message.valueOf(trx.getStateMachineLogEntry().getLogData()));
content of client request will be injected to StateMachineEntryProto at leader,
static StateMachineLogEntryProto toStateMachineLogEntryProto( RaftClientRequest request, ByteString logData, ByteString stateMachineData) { if (logData == null) { logData = request.getMessage().getContent(); } return toStateMachineLogEntryProto(request.getClientId(), request.getCallId(), logData, stateMachineData); }
and extracted from log entry at follower.
/** * 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(); }
Attachments
Issue Links
- links to