Skip to content

Commit

Permalink
#1114 - add TX_PREPARING_STATE state for mysql connection in xa trans…
Browse files Browse the repository at this point in the history
…action (#1130)
  • Loading branch information
PanternBao authored and yanhuqing666 committed Apr 23, 2019
1 parent b41e73f commit 102515a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/actiontech/dble/DbleServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,8 @@ private void tryRecovery(CoordinatorLogEntry coordinatorLogEntry, boolean needCo
participantLogEntry.getTxState() != TxState.TX_PREPARE_UNCONNECT_STATE &&
participantLogEntry.getTxState() != TxState.TX_ROLLBACKING_STATE &&
participantLogEntry.getTxState() != TxState.TX_ROLLBACK_FAILED_STATE &&
participantLogEntry.getTxState() != TxState.TX_PREPARED_STATE) {
participantLogEntry.getTxState() != TxState.TX_PREPARED_STATE &&
participantLogEntry.getTxState() != TxState.TX_PREPARING_STATE) {
continue;
}
finished = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ protected boolean executeCommit(MySQLConnection mysqlCon, int position) {
}
this.debugCommitDelay();
}

preparePhase(mysqlCon);
} else if (state == TxState.TX_PREPARED_STATE) {
if (position == 0) {
Expand Down Expand Up @@ -179,6 +180,9 @@ private void preparePhase(MySQLConnection mysqlCon) {
String xaTxId = mysqlCon.getConnXID(session);
String rrnName = ((RouteResultsetNode) mysqlCon.getAttachment()).getName();
XaDelayProvider.delayBeforeXaPrepare(rrnName, xaTxId);
// update state of mysql conn to TX_PREPARING_STATE
mysqlCon.setXaStatus(TxState.TX_PREPARING_STATE);
XAStateLog.saveXARecoveryLog(session.getSessionXaID(), mysqlCon);
mysqlCon.execCmd("XA PREPARE " + xaTxId);
}

Expand Down Expand Up @@ -211,7 +215,7 @@ public void okResponse(byte[] ok, BackendConnection conn) {
session.setXaState(TxState.TX_ENDED_STATE);
nextParse();
}
} else if (state == TxState.TX_ENDED_STATE) {
} else if (state == TxState.TX_PREPARING_STATE) {
//PREPARE OK
mysqlCon.setXaStatus(TxState.TX_PREPARED_STATE);
XAStateLog.saveXARecoveryLog(session.getSessionXaID(), mysqlCon);
Expand Down

0 comments on commit 102515a

Please sign in to comment.