forked from apache/incubator-seata
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: TCC mode support idempotent and anti hanging (apache#3545)
- Loading branch information
Showing
26 changed files
with
1,247 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- -------------------------------- The script use tcc fence -------------------------------- | ||
CREATE TABLE IF NOT EXISTS `tcc_fence_log` | ||
( | ||
`xid` VARCHAR(128) NOT NULL COMMENT 'global id', | ||
`branch_id` BIGINT NOT NULL COMMENT 'branch id', | ||
`status` TINYINT NOT NULL COMMENT 'status(tried:1;committed:2;rollbacked:3;suspended:4)', | ||
`gmt_create` DATETIME(3) NOT NULL COMMENT 'create time', | ||
`gmt_modified` DATETIME(3) NOT NULL COMMENT 'update time', | ||
PRIMARY KEY (`xid`, `branch_id`), | ||
KEY `idx_gmt_modified` (`gmt_modified`), | ||
KEY `idx_status` (`status`) | ||
) ENGINE = InnoDB | ||
DEFAULT CHARSET = utf8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CREATE TABLE tcc_fence_log | ||
( | ||
xid VARCHAR2(128) NOT NULL, | ||
branch_id NUMBER(19) NOT NULL, | ||
status NUMBER(3) NOT NULL, | ||
gmt_create TIMESTAMP(3) NOT NULL, | ||
gmt_modified TIMESTAMP(3) NOT NULL, | ||
PRIMARY KEY (xid, branch_id) | ||
); | ||
CREATE INDEX idx_gmt_modified ON tcc_fence_log (gmt_modified); | ||
CREATE INDEX idx_status ON tcc_fence_log (status); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
-- -------------------------------- The script used for tcc fence -------------------------------- | ||
CREATE TABLE IF NOT EXISTS public.tcc_fence_log | ||
( | ||
xid VARCHAR(128) NOT NULL, | ||
branch_id BIGINT NOT NULL, | ||
status SMALLINT NOT NULL, | ||
gmt_create TIMESTAMP(3) NOT NULL, | ||
gmt_modified TIMESTAMP(3) NOT NULL, | ||
CONSTRAINT pk_tcc_fence_log PRIMARY KEY (xid, branch_id) | ||
); | ||
CREATE INDEX idx_gmt_modified ON public.tcc_fence_log (gmt_modified); | ||
CREATE INDEX idx_status ON public.tcc_fence_log (status); |
58 changes: 58 additions & 0 deletions
58
...ient/src/main/java/io/seata/spring/boot/autoconfigure/SeataTCCFenceAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 1999-2019 Seata.io Group. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.seata.spring.boot.autoconfigure; | ||
|
||
import io.seata.rm.tcc.config.TCCFenceConfig; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Qualifier; | ||
import org.springframework.boot.autoconfigure.AutoConfigureAfter; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.transaction.PlatformTransactionManager; | ||
|
||
import javax.sql.DataSource; | ||
|
||
/** | ||
* TCC fence auto configuration. | ||
* | ||
* @author kaka2code | ||
*/ | ||
@ConditionalOnExpression("${seata.enabled:true} && ${seata.tccFence.enabled:true} && ${seata.tcc-fence.enabled:true}") | ||
@AutoConfigureAfter({DataSourceAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class}) | ||
public class SeataTCCFenceAutoConfiguration { | ||
|
||
public static final String TCC_FENCE_DATA_SOURCE_BEAN_NAME = "seataTCCFenceDataSource"; | ||
public static final String TCC_FENCE_TRANSACTION_MANAGER_BEAN_NAME = "seataTCCFenceTransactionManager"; | ||
|
||
@Bean | ||
@ConditionalOnMissingBean(TCCFenceConfig.class) | ||
@ConditionalOnBean({DataSource.class, PlatformTransactionManager.class}) | ||
@ConfigurationProperties(StarterConstants.TCC_FENCE_CONFIG_PREFIX_KEBAB_STYLE) | ||
public TCCFenceConfig tccFenceConfig( | ||
DataSource dataSource, | ||
PlatformTransactionManager transactionManager, | ||
@Qualifier(TCC_FENCE_DATA_SOURCE_BEAN_NAME) @Autowired(required = false) DataSource tccFenceDataSource, | ||
@Qualifier(TCC_FENCE_TRANSACTION_MANAGER_BEAN_NAME) @Autowired(required = false) PlatformTransactionManager tccFenceTransactionManager) { | ||
return new TCCFenceConfig(tccFenceDataSource != null ? tccFenceDataSource : dataSource, | ||
tccFenceTransactionManager != null ? tccFenceTransactionManager : transactionManager); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
...oconfigure/seata-spring-autoconfigure-client/src/main/resources/META-INF/spring.factories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# Auto Configure | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=io.seata.spring.boot.autoconfigure.SeataClientPropertiesAutoConfiguration | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ | ||
io.seata.spring.boot.autoconfigure.SeataClientPropertiesAutoConfiguration,\ | ||
io.seata.spring.boot.autoconfigure.SeataTCCFenceAutoConfiguration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.