Skip to content

HBASE-28212 Do not need to maintain rollback step when root procedure… #5547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ public enum LockState {
private RemoteProcedureException exception = null;
private int[] stackIndexes = null;
private int childrenLatch = 0;
// since we do not always maintain stackIndexes if the root procedure does not support rollback,
// we need a separated flag to indicate whether a procedure was executed
private boolean wasExecuted;

private volatile int timeout = NO_TIMEOUT;
private volatile long lastUpdate;
Expand Down Expand Up @@ -871,6 +874,7 @@ protected synchronized void addStackIndex(final int index) {
stackIndexes = Arrays.copyOf(stackIndexes, count + 1);
stackIndexes[count] = index;
}
wasExecuted = true;
}

protected synchronized boolean removeStackIndex() {
Expand All @@ -891,16 +895,32 @@ protected synchronized void setStackIndexes(final List<Integer> stackIndexes) {
for (int i = 0; i < this.stackIndexes.length; ++i) {
this.stackIndexes[i] = stackIndexes.get(i);
}
// for backward compatible, where a procedure is serialized before we added the executed flag,
// the flag will be false so we need to set the wasExecuted flag here
this.wasExecuted = true;
}

protected synchronized void setExecuted() {
this.wasExecuted = true;
}

protected synchronized boolean wasExecuted() {
return stackIndexes != null;
return wasExecuted;
}

protected synchronized int[] getStackIndexes() {
return stackIndexes;
}

/**
* Return whether the procedure supports rollback. If the procedure does not support rollback, we
* can skip the rollback state management which could increase the performance. See HBASE-28210
* and HBASE-28212.
*/
protected boolean isRollbackSupported() {
return true;
}

// ==========================================================================
// Internal methods - called by the ProcedureExecutor
// ==========================================================================
Expand Down
Loading