protected synchronized void loadStack(Procedure<TEnvironment> proc) {
    addSubProcedure(proc);
    int[] stackIndexes = proc.getStackIndexes();
    if (stackIndexes != null) {
      if (subprocStack == null) {
        subprocStack = new ArrayList<>();
      }
      int diff = (1 + stackIndexes[stackIndexes.length - 1]) - subprocStack.size();
      if (diff > 0) {
        subprocStack.ensureCapacity(1 + stackIndexes[stackIndexes.length - 1]);
        while (diff-- > 0) {
          subprocStack.add(null);
        }
      }
      for (int i = 0; i < stackIndexes.length; ++i) {
        subprocStack.set(stackIndexes[i], proc);
      }
    }
    if (proc.getState() == ProcedureState.ROLLEDBACK) {
      state = State.ROLLINGBACK;
    } else if (proc.isFailed()) {
      state = State.FAILED;
    }
  }
Called on store load by the ProcedureExecutor to load part of the stack. Each procedure has its
own stack-positions. Which means we have to write to the store only the Procedure we executed,
and nothing else. on load we recreate the full stack by aggregating each procedure
stack-positions.
hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/RootProcedureState.java