@@ -133,6 +133,9 @@ public enum LockState {
133133 private RemoteProcedureException exception = null ;
134134 private int [] stackIndexes = null ;
135135 private int childrenLatch = 0 ;
136+ // since we do not always maintain stackIndexes if the root procedure does not support rollback,
137+ // we need a separated flag to indicate whether a procedure was executed
138+ private boolean wasExecuted ;
136139
137140 private volatile int timeout = NO_TIMEOUT ;
138141 private volatile long lastUpdate ;
@@ -870,6 +873,7 @@ protected synchronized void addStackIndex(final int index) {
870873 stackIndexes = Arrays .copyOf (stackIndexes , count + 1 );
871874 stackIndexes [count ] = index ;
872875 }
876+ wasExecuted = true ;
873877 }
874878
875879 protected synchronized boolean removeStackIndex () {
@@ -890,16 +894,32 @@ protected synchronized void setStackIndexes(final List<Integer> stackIndexes) {
890894 for (int i = 0 ; i < this .stackIndexes .length ; ++i ) {
891895 this .stackIndexes [i ] = stackIndexes .get (i );
892896 }
897+ // for backward compatible, where a procedure is serialized before we added the executed flag,
898+ // the flag will be false so we need to set the wasExecuted flag here
899+ this .wasExecuted = true ;
900+ }
901+
902+ protected synchronized void setExecuted () {
903+ this .wasExecuted = true ;
893904 }
894905
895906 protected synchronized boolean wasExecuted () {
896- return stackIndexes != null ;
907+ return wasExecuted ;
897908 }
898909
899910 protected synchronized int [] getStackIndexes () {
900911 return stackIndexes ;
901912 }
902913
914+ /**
915+ * Return whether the procedure supports rollback. If the procedure does not support rollback, we
916+ * can skip the rollback state management which could increase the performance. See HBASE-28210
917+ * and HBASE-28212.
918+ */
919+ protected boolean isRollbackSupported () {
920+ return true ;
921+ }
922+
903923 // ==========================================================================
904924 // Internal methods - called by the ProcedureExecutor
905925 // ==========================================================================
0 commit comments