seata源码解析:seata是如何支持TCC模式的?
作者:互联网
介绍
增加了横切逻辑实现类
一阶段开启分支事务
TccActionInterceptor
二阶段提交/回滚分支事务
DefaultCore#commit
TCCResourceManager#branchCommit
CREATE TABLE IF NOT EXISTS `global_table`
(
`xid` VARCHAR(128) NOT NULL,
`transaction_id` BIGINT,
`status` TINYINT NOT NULL,
`application_id` VARCHAR(32),
`transaction_service_group` VARCHAR(32),
`transaction_name` VARCHAR(128),
`timeout` INT,
`begin_time` BIGINT,
`application_data` VARCHAR(2000),
`gmt_create` DATETIME,
`gmt_modified` DATETIME,
PRIMARY KEY (`xid`),
KEY `idx_gmt_modified_status` (`gmt_modified`, `status`),
KEY `idx_transaction_id` (`transaction_id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
-- the table to store BranchSession data
CREATE TABLE IF NOT EXISTS `branch_table`
(
`branch_id` BIGINT NOT NULL,
`xid` VARCHAR(128) NOT NULL,
`transaction_id` BIGINT,
`resource_group_id` VARCHAR(32),
`resource_id` VARCHAR(256),
`branch_type` VARCHAR(8),
`status` TINYINT,
`client_id` VARCHAR(64),
`application_data` VARCHAR(2000),
`gmt_create` DATETIME(6),
`gmt_modified` DATETIME(6),
PRIMARY KEY (`branch_id`),
KEY `idx_xid` (`xid`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
-- the table to store lock data
CREATE TABLE IF NOT EXISTS `lock_table`
(
`row_key` VARCHAR(128) NOT NULL,
`xid` VARCHAR(128),
`transaction_id` BIGINT,
`branch_id` BIGINT NOT NULL,
`resource_id` VARCHAR(256),
`table_name` VARCHAR(32),
`pk` VARCHAR(36),
`gmt_create` DATETIME,
`gmt_modified` DATETIME,
PRIMARY KEY (`row_key`),
KEY `idx_branch_id` (`branch_id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
global_table
172.21.0.14:18091:6449338273221152788,6449338273221152788,1,seata-tcc-tm,my_test_tx_group,“transfer(java.lang.String, java.lang.String, java.lang.Integer)”,60000,1633261303962,2021-10-03 19:41:43,2021-10-03 19:41:43
branch_table
6449338273221152790,172.21.0.14:18091:6449338273221152788,6449338273221152788,prepare,TCC,0,seata-tcc-tm:219.238.205.162:30726,"{"“actionContext”":{"“action-start-time”":1633261303972,"“money”":200,"“sys::prepare”":"“prepare”","“fromUserId”":"“1001"”,"“sys::rollback”":"“cancel”","“sys::commit”":"“commit”","“host-name”":"“192.168.97.57"”,"“toUserId”":"“1002"”,"“actionName”":"“prepare”"}}",2021-10-03 19:41:43,2021-10-03 19:41:43
6449338273221152792,172.21.0.14:18091:6449338273221152788,6449338273221152788,prepare,TCC,0,seata-tcc-rm:219.238.205.162:30537,"{"“actionContext”":{"“action-start-time”":1633261304008,"“money”":200,"“sys::prepare”":"“prepare”","“fromUserId”":"“1001"”,"“sys::rollback”":"“cancel”","“sys::commit”":"“commit”","“host-name”":"“192.168.97.57"”,"“toUserId”":"“1002"”,"“actionName”":"“prepare”"}}",2021-10-03 19:41:44,2021-10-03 19:41:44
参考博客
[1]https://blog.csdn.net/zjj2006/article/details/108959939
[2]https://zhuanlan.zhihu.com/p/271735569
标签:VARCHAR,seata,prepare,TCC,源码,branch,table,id,gmt 来源: https://blog.csdn.net/zzti_erlie/article/details/120595323