Skip to content

Commit 8f70d84

Browse files
committed
HBASE-28212 Do not need to maintain rollback step when root procedure does not support rollback (#5538) (#5547)
Signed-off-by: GeorryHuang <huangzhuoyue@apache.org> (cherry picked from commit 4b015e6)
1 parent 42851f6 commit 8f70d84

File tree

13 files changed

+576
-153
lines changed

13 files changed

+576
-153
lines changed

hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/Procedure.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ public enum LockState {
131131
private RemoteProcedureException exception = null;
132132
private int[] stackIndexes = null;
133133
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;
134137

135138
private volatile int timeout = NO_TIMEOUT;
136139
private volatile long lastUpdate;
@@ -871,6 +874,7 @@ protected synchronized void addStackIndex(final int index) {
871874
stackIndexes = Arrays.copyOf(stackIndexes, count + 1);
872875
stackIndexes[count] = index;
873876
}
877+
wasExecuted = true;
874878
}
875879

876880
protected synchronized boolean removeStackIndex() {
@@ -891,16 +895,32 @@ protected synchronized void setStackIndexes(final List<Integer> stackIndexes) {
891895
for (int i = 0; i < this.stackIndexes.length; ++i) {
892896
this.stackIndexes[i] = stackIndexes.get(i);
893897
}
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;
894905
}
895906

896907
protected synchronized boolean wasExecuted() {
897-
return stackIndexes != null;
908+
return wasExecuted;
898909
}
899910

900911
protected synchronized int[] getStackIndexes() {
901912
return stackIndexes;
902913
}
903914

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+
904924
// ==========================================================================
905925
// Internal methods - called by the ProcedureExecutor
906926
// ==========================================================================

0 commit comments

Comments
 (0)