public void serialize(DataOutputStream stream) throws IOException {
    // procid
    stream.writeLong(this.procId);
    // state
    stream.writeInt(this.state.ordinal());
    // submit time
    stream.writeLong(this.submittedTime);
    // last updated
    stream.writeLong(this.lastUpdate);
    // parent id
    stream.writeLong(this.parentProcId);
    // time out
    stream.writeLong(this.timeout);
    // stack indexes
    if (stackIndexes != null) {
      stream.writeInt(stackIndexes.length);
      for (int index : stackIndexes) {
        stream.writeInt(index);
      }
    } else {
      stream.writeInt(-1);
    }

    // exceptions
    if (hasException()) {
      // symbol of exception
      stream.write((byte) 1);
      // exception's name
      String exceptionClassName = exception.getClass().getName();
      byte[] exceptionClassNameBytes = exceptionClassName.getBytes(StandardCharsets.UTF_8);
      stream.writeInt(exceptionClassNameBytes.length);
      stream.write(exceptionClassNameBytes);
      // exception's message
      String message = this.exception.getMessage();
      if (message != null) {
        byte[] messageBytes = message.getBytes(StandardCharsets.UTF_8);
        stream.writeInt(messageBytes.length);
        stream.write(messageBytes);
      } else {
        stream.writeInt(-1);
      }
    } else {
      // symbol of no exception
      stream.write((byte) 0);
    }

    // result
    if (result.get() != null) {
      stream.writeInt(result.get().length);
      stream.write(result.get());
    } else {
      stream.writeInt(-1);
    }

    // Has lock
    stream.write(this.hasLock() ? (byte) 1 : (byte) 0);
  }
The code to undo what was done by the execute() code. It is called when the procedure or one of
the sub-procedures failed or an abort was requested. It should cleanup all the resources
created by the execute() call. The implementation must be idempotent since rollback() may be
called multiple time in case of machine failure in the middle of the execution.

@param env the environment passed to the ProcedureExecutor
@throws IOException temporary failure, the rollback will retry later
@throws InterruptedException the procedure will be added back to the queue and retried later
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/Procedure.java