Skip to content

Commit

Permalink
fix not rollback if commitPartOfEdgeDeletions() fails (apache#1513)
Browse files Browse the repository at this point in the history
Change-Id: Ic7b03c25fc00605980d461245b5d3c4b911a7d86
  • Loading branch information
javeme authored Jun 24, 2021
1 parent ab69c8b commit b43ab45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ public void rollback() throws BackendException {
LOG.debug("Transaction rollback()...");
this.reset();
if (this.committing2Backend) {
this.committing2Backend = false;
this.store.rollbackTx();
this.rollbackBackend();
}
}

Expand Down Expand Up @@ -301,6 +300,11 @@ protected void commitMutation2Backend(BackendMutation... mutations) {
this.committing2Backend = false;
}

protected void rollbackBackend() {
this.committing2Backend = false;
this.store.rollbackTx();
}

protected BackendMutation prepareCommit() {
// For sub-class preparing data, nothing to do here
LOG.debug("Transaction prepareCommit()...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
import com.baidu.hugegraph.iterator.LimitIterator;
import com.baidu.hugegraph.iterator.ListIterator;
import com.baidu.hugegraph.iterator.MapperIterator;
import com.baidu.hugegraph.iterator.WrappedIterator;
import com.baidu.hugegraph.job.system.DeleteExpiredJob;
import com.baidu.hugegraph.perf.PerfUtil.Watched;
import com.baidu.hugegraph.schema.EdgeLabel;
Expand Down Expand Up @@ -483,6 +482,8 @@ private void commitPartOfEdgeDeletions(Map<Id, HugeEdge> removedEdges) {

try {
this.commitMutation2Backend(mutation, idxMutation);
} catch (Throwable e) {
this.rollbackBackend();
} finally {
mutation.clear();
idxMutation.clear();
Expand Down

0 comments on commit b43ab45

Please sign in to comment.