@@ -133,6 +133,9 @@ public enum LockState {
133
133
private RemoteProcedureException exception = null ;
134
134
private int [] stackIndexes = null ;
135
135
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 ;
136
139
137
140
private volatile int timeout = NO_TIMEOUT ;
138
141
private volatile long lastUpdate ;
@@ -870,6 +873,7 @@ protected synchronized void addStackIndex(final int index) {
870
873
stackIndexes = Arrays .copyOf (stackIndexes , count + 1 );
871
874
stackIndexes [count ] = index ;
872
875
}
876
+ wasExecuted = true ;
873
877
}
874
878
875
879
protected synchronized boolean removeStackIndex () {
@@ -890,16 +894,32 @@ protected synchronized void setStackIndexes(final List<Integer> stackIndexes) {
890
894
for (int i = 0 ; i < this .stackIndexes .length ; ++i ) {
891
895
this .stackIndexes [i ] = stackIndexes .get (i );
892
896
}
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 ;
893
904
}
894
905
895
906
protected synchronized boolean wasExecuted () {
896
- return stackIndexes != null ;
907
+ return wasExecuted ;
897
908
}
898
909
899
910
protected synchronized int [] getStackIndexes () {
900
911
return stackIndexes ;
901
912
}
902
913
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
+
903
923
// ==========================================================================
904
924
// Internal methods - called by the ProcedureExecutor
905
925
// ==========================================================================
0 commit comments