Skip to content
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

#1114 - add TX_PREPARING_STATE state for mysql connection in xa transaction #1130

Merged
merged 2 commits into from
Apr 23, 2019
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
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