@@ -131,6 +131,9 @@ public enum LockState {
131
131
private RemoteProcedureException exception = null ;
132
132
private int [] stackIndexes = null ;
133
133
private int childrenLatch = 0 ;
134
+ // since we do not always maintain stackIndexes if the root procedure does not support rollback,
135
+ // we need a separated flag to indicate whether a procedure was executed
136
+ private boolean wasExecuted ;
134
137
135
138
private volatile int timeout = NO_TIMEOUT ;
136
139
private volatile long lastUpdate ;
@@ -871,6 +874,7 @@ protected synchronized void addStackIndex(final int index) {
871
874
stackIndexes = Arrays .copyOf (stackIndexes , count + 1 );
872
875
stackIndexes [count ] = index ;
873
876
}
877
+ wasExecuted = true ;
874
878
}
875
879
876
880
protected synchronized boolean removeStackIndex () {
@@ -891,16 +895,32 @@ protected synchronized void setStackIndexes(final List<Integer> stackIndexes) {
891
895
for (int i = 0 ; i < this .stackIndexes .length ; ++i ) {
892
896
this .stackIndexes [i ] = stackIndexes .get (i );
893
897
}
898
+ // for backward compatible, where a procedure is serialized before we added the executed flag,
899
+ // the flag will be false so we need to set the wasExecuted flag here
900
+ this .wasExecuted = true ;
901
+ }
902
+
903
+ protected synchronized void setExecuted () {
904
+ this .wasExecuted = true ;
894
905
}
895
906
896
907
protected synchronized boolean wasExecuted () {
897
- return stackIndexes != null ;
908
+ return wasExecuted ;
898
909
}
899
910
900
911
protected synchronized int [] getStackIndexes () {
901
912
return stackIndexes ;
902
913
}
903
914
915
+ /**
916
+ * Return whether the procedure supports rollback. If the procedure does not support rollback, we
917
+ * can skip the rollback state management which could increase the performance. See HBASE-28210
918
+ * and HBASE-28212.
919
+ */
920
+ protected boolean isRollbackSupported () {
921
+ return true ;
922
+ }
923
+
904
924
// ==========================================================================
905
925
// Internal methods - called by the ProcedureExecutor
906
926
// ==========================================================================
0 commit comments