里面比较迷糊的其实就是status字段的含义 ,直接copy源码了 ,做下记录
public enum GlobalStatus {
/**
* Un known global status.
*/
// Unknown
UnKnown(0),
/**
* The Begin.
*/
// PHASE 1: can accept new branch registering.
Begin(1),
/**
* PHASE 2: Running Status: may be changed any time.
*/
// Committing.
Committing(2),
/**
* The Commit retrying.
*/
// Retrying commit after a recoverable failure.
CommitRetrying(3),
/**
* Rollbacking global status.
*/
// Rollbacking
Rollbacking(4),
/**
* The Rollback retrying.
*/
// Retrying rollback after a recoverable failure.
RollbackRetrying(5),
/**
* The Timeout rollbacking.
*/
// Rollbacking since timeout
TimeoutRollbacking(6),
/**
* The Timeout rollback retrying.
*/
// Retrying rollback (since timeout) after a recoverable failure.
TimeoutRollbackRetrying(7),
/**
* All branches can be async committed. The committing is NOT done yet, but it can be seen as committed for TM/RM
* client.
*/
AsyncCommitting(8),
/**
* PHASE 2: Final Status: will NOT change any more.
*/
// Finally: global transaction is successfully committed.
Committed(9),
/**
* The Commit failed.
*/
// Finally: failed to commit
CommitFailed(10),
/**
* The Rollbacked.
*/
// Finally: global transaction is successfully rollbacked.
Rollbacked(11),
/**
* The Rollback failed.
*/
// Finally: failed to rollback
RollbackFailed(12),
/**
* The Timeout rollbacked.
*/
// Finally: global transaction is successfully rollbacked since timeout.
TimeoutRollbacked(13),
/**
* The Timeout rollback failed.
*/
// Finally: failed to rollback since timeout
TimeoutRollbackFailed(14),
/**
* The Finished.
*/
// Not managed in session MAP any more
Finished(15);
}
DROP TABLE IF EXISTS `global_table`;
CREATE TABLE `global_table` (
`xid` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
`transaction_id` bigint(20) DEFAULT NULL,
`status` tinyint(4) NOT NULL,
`application_id` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`transaction_service_group` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`transaction_name` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`timeout` int(11) DEFAULT NULL,
`begin_time` bigint(20) DEFAULT NULL,
`application_data` varchar(2000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
`gmt_create` datetime(0) DEFAULT NULL,
`gmt_modified` datetime(0) DEFAULT NULL,
PRIMARY KEY (`xid`) USING BTREE,
INDEX `idx_gmt_modified_status`(`gmt_modified`, `status`) USING BTREE,
INDEX `idx_transaction_id`(`transaction_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;