public TSStatus getFailureStatus() {
    if (failureStatus != null) {
      return failureStatus;
    } else if (failureException != null) {
      Throwable t = getRootCause(failureException);
      if (t instanceof IoTDBRuntimeException) {
        return RpcUtils.getStatus(((IoTDBRuntimeException) t).getErrorCode(), t.getMessage());
      } else if (t instanceof IoTDBException) {
        return RpcUtils.getStatus(((IoTDBException) t).getErrorCode(), t.getMessage());
      }
    }
    return failureStatus;
  }
State machine for a {@link QueryExecution}. It stores the states for the {@link QueryExecution}.
Others can register listeners when the state changes of the {@link QueryExecution}.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/QueryStateMachine.java