Skip to content

Commit

Permalink
bugfix: global status inconsistent when rollback and branch register …
Browse files Browse the repository at this point in the history
…are concurrent (apache#1825)
  • Loading branch information
zjinlei committed Nov 11, 2019
1 parent f6bfa7a commit 8edb5b8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,16 @@ public void doGlobalRollback(GlobalSession globalSession, boolean retrying) thro
}
throw new TransactionException(ex);
}
}

//In db mode, there is a problem of inconsistent data in multiple copies, resulting in new branch transaction registration when rolling back.
//1. New branch transaction and rollback branch transaction have no data association
//2. New branch transaction has data association with rollback branch transaction
//The second query can solve the first problem, and if it is the second problem, it may cause a rollback failure due to data changes.
GlobalSession globalSessionTwice = SessionHolder.findGlobalSession(globalSession.getXid());
if (globalSessionTwice != null && globalSessionTwice.hasBranch()) {
LOGGER.info("Global[{}] rollbacking is NOT done.", globalSession.getXid());
return;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,20 @@ public synchronized void init() {
@Override
public boolean writeSession(LogOperation logOperation, SessionStorable session) {
if (LogOperation.GLOBAL_ADD.equals(logOperation)) {
logStore.insertGlobalTransactionDO(convertGlobalTransactionDO(session));
return logStore.insertGlobalTransactionDO(convertGlobalTransactionDO(session));
} else if (LogOperation.GLOBAL_UPDATE.equals(logOperation)) {
logStore.updateGlobalTransactionDO(convertGlobalTransactionDO(session));
return logStore.updateGlobalTransactionDO(convertGlobalTransactionDO(session));
} else if (LogOperation.GLOBAL_REMOVE.equals(logOperation)) {
logStore.deleteGlobalTransactionDO(convertGlobalTransactionDO(session));
return logStore.deleteGlobalTransactionDO(convertGlobalTransactionDO(session));
} else if (LogOperation.BRANCH_ADD.equals(logOperation)) {
logStore.insertBranchTransactionDO(convertBranchTransactionDO(session));
return logStore.insertBranchTransactionDO(convertBranchTransactionDO(session));
} else if (LogOperation.BRANCH_UPDATE.equals(logOperation)) {
logStore.updateBranchTransactionDO(convertBranchTransactionDO(session));
return logStore.updateBranchTransactionDO(convertBranchTransactionDO(session));
} else if (LogOperation.BRANCH_REMOVE.equals(logOperation)) {
logStore.deleteBranchTransactionDO(convertBranchTransactionDO(session));
return logStore.deleteBranchTransactionDO(convertBranchTransactionDO(session));
} else {
throw new StoreException("Unknown LogOperation:" + logOperation.name());
}
return true;
}

/**
Expand Down

0 comments on commit 8edb5b8

Please sign in to comment.