Uploaded image for project: 'Apache Ozone'
  1. Apache Ozone
  2. HDDS-2823 SCM HA Support
  3. HDDS-4059

SCMStateMachine::applyTransaction() should not invoke TransactionContext.getClientRequest()

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • None
    • SCM

    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

          Activity

            People

              glengeng Glen Geng
              glengeng Glen Geng
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: