Skip to content

Commit

Permalink
optimize: lazily load branch transactions and task scheduling (apach…
Browse files Browse the repository at this point in the history
  • Loading branch information
funky-eyes authored Feb 14, 2022
1 parent f1be649 commit e4ae6b7
Show file tree
Hide file tree
Showing 29 changed files with 355 additions and 238 deletions.
2 changes: 2 additions & 0 deletions changes/1.5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,14 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单
- [[#4019](https://github.com/seata/seata/pull/4019)] 优化 Nacos、Consul、Zookeeper、Etcd3 配置
- [[#4034](https://github.com/seata/seata/pull/4034)] 优化“优化 Nacos、Consul、Zookeeper、Etcd3 配置(#4019)”的单元测试类
- [[#4055](https://github.com/seata/seata/pull/4055)] 优化NetUtil的getLocalAddress0方法
- [[#4086](https://github.com/seata/seata/pull/4086)] 分支事务支持懒加载并优化任务调度
- [[#4056](https://github.com/seata/seata/pull/4056)] 优化 DurationUtil
- [[#4103](https://github.com/seata/seata/pull/4103)] 减少分支事务注册无需竞争锁时的内存占用
- [[#3733](https://github.com/seata/seata/pull/3733)] 优化本地事务下的锁竞争机制
- [[#4144](https://github.com/seata/seata/pull/4144)] 支持默认的事务分组配置
- [[#4157](https://github.com/seata/seata/pull/4157)] 优化客户端批量发送请求
- [[#4191](https://github.com/seata/seata/pull/4191)] RPC请求超时时间支持配置化
- [[#4216](https://github.com/seata/seata/pull/4216)] 非AT模式无须清理undolog表
- [[#4176](https://github.com/seata/seata/pull/4176)] 优化redis注册中心存储,改用自动过期key替代hash.
- [[#4196](https://github.com/seata/seata/pull/4196)] TC 批量响应客户端
- [[#4212](https://github.com/seata/seata/pull/4212)] 控制台接口合并优化
Expand Down
3 changes: 2 additions & 1 deletion changes/en-us/1.5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,18 @@
- [[#4019](https://github.com/seata/seata/pull/4019)] optimize Nacos、Consul、Zookeeper、Etcd3 configuration
- [[#4034](https://github.com/seata/seata/pull/4034)] optimize Nacos, Consul, Zookeeper and Etcd3 configuration Junit test Class
- [[#4055](https://github.com/seata/seata/pull/4055)] optimize NetUtil#getLocalAddress0
- [[#4086](https://github.com/seata/seata/pull/4086)] optimize lazily load branch transactions and task scheduling
- [[#4056](https://github.com/seata/seata/pull/4056)] optimize the DurationUtil
- [[#4103](https://github.com/seata/seata/pull/4103)] optimize AbstractLockManager#collectRowLocks logic
- [[#3733](https://github.com/seata/seata/pull/3733)] optimize acquire lock logic
- [[#4103](https://github.com/seata/seata/pull/4103)] optimize AbstractLockManager#collectRowLocks logic
- [[#4144](https://github.com/seata/seata/pull/4144)] support default configuration of tx-service-group
- [[#4157](https://github.com/seata/seata/pull/4157)] optimize client batch sending.
- [[#4191](https://github.com/seata/seata/pull/4191)] support rpc timeout can be customized.
- [[#4216](https://github.com/seata/seata/pull/4216)] no more attempt to clean undolog for none AT mode
- [[#4176](https://github.com/seata/seata/pull/4176)] use expire key instead hash when using redis as registry center.
- [[#4196](https://github.com/seata/seata/pull/4196)] tc batch response to client.
- [[#4212](https://github.com/seata/seata/pull/4212)] optimize the interface of the console
- [[#4216](https://github.com/seata/seata/pull/4216)] no more attempt to clean undolog for none AT user
- [[#4237](https://github.com/seata/seata/pull/4237)] skip check lock when all the before image is empty
- [[#4251](https://github.com/seata/seata/pull/4251)] optimize partial code handling
- [[#4262](https://github.com/seata/seata/pull/4262)] optimize tcc module code handling
Expand Down
18 changes: 2 additions & 16 deletions common/src/main/java/io/seata/common/ConfigurationKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -362,25 +362,11 @@ public interface ConfigurationKeys {
* The constant RECOVERY_PREFIX.
*/
String RECOVERY_PREFIX = SERVER_PREFIX + "recovery.";
/**
* The constant COMMITING_RETRY_PERIOD.
*/
String COMMITING_RETRY_PERIOD = RECOVERY_PREFIX + "committingRetryPeriod";

/**
* The constant ASYN_COMMITING_RETRY_PERIOD.
*/
String ASYN_COMMITING_RETRY_PERIOD = RECOVERY_PREFIX + "asynCommittingRetryPeriod";

/**
* The constant ROLLBACKING_RETRY_PERIOD.
*/
String ROLLBACKING_RETRY_PERIOD = RECOVERY_PREFIX + "rollbackingRetryPeriod";

/**
* The constant TIMEOUT_RETRY_PERIOD.
* The constant HANDLE_ALL_SESSION_PERIOD.
*/
String TIMEOUT_RETRY_PERIOD = RECOVERY_PREFIX + "timeoutRetryPeriod";
String HANDLE_ALL_SESSION_PERIOD = RECOVERY_PREFIX + "handleAllSessionPeriod";

/**
* The constant CLIENT_UNDO_PREFIX.
Expand Down
5 changes: 5 additions & 0 deletions common/src/main/java/io/seata/common/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ public interface Constants {
*/
String RETRY_ROLLBACKING = "RetryRollbacking";

/**
* The constant HANDLE_ALL_SESSION
*/
String HANDLE_ALL_SESSION = "HandleAllSession";

/**
* The constant RETRY_COMMITTING
*/
Expand Down
7 changes: 2 additions & 5 deletions script/server/db/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CREATE TABLE IF NOT EXISTS `global_table`
`gmt_create` DATETIME,
`gmt_modified` DATETIME,
PRIMARY KEY (`xid`),
KEY `idx_gmt_modified_status` (`gmt_modified`, `status`),
KEY `idx_status_gmt_modified` (`status` , `gmt_modified`),
KEY `idx_transaction_id` (`transaction_id`)
) ENGINE = InnoDB
DEFAULT CHARSET = utf8;
Expand Down Expand Up @@ -66,7 +66,4 @@ CREATE TABLE IF NOT EXISTS `distributed_lock`
) ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4;

INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('AsyncCommitting', ' ', 0);
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('RetryCommitting', ' ', 0);
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('RetryRollbacking', ' ', 0);
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);
INSERT INTO `distributed_lock` (lock_key, lock_value, expire) VALUES ('HandleAllSession', ' ', 0);
7 changes: 2 additions & 5 deletions script/server/db/oracle.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ CREATE TABLE global_table
PRIMARY KEY (xid)
);

CREATE INDEX idx_gmt_modified_status ON global_table (gmt_modified, status);
CREATE INDEX idx_status_gmt_modified ON global_table (status, gmt_modified);
CREATE INDEX idx_transaction_id ON global_table (transaction_id);

-- the table to store BranchSession data
Expand Down Expand Up @@ -65,8 +65,5 @@ CREATE TABLE distributed_lock (
PRIMARY KEY (lock_key)
);

INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('AsyncCommitting', ' ', 0);
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('RetryCommitting', ' ', 0);
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('RetryRollbacking', ' ', 0);
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('HandleAllSession', ' ', 0);

7 changes: 2 additions & 5 deletions script/server/db/postgresql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS public.global_table
CONSTRAINT pk_global_table PRIMARY KEY (xid)
);

CREATE INDEX idx_gmt_modified_status ON public.global_table (gmt_modified, status);
CREATE INDEX idx_status_gmt_modified ON public.global_table (status, gmt_modified);
CREATE INDEX idx_transaction_id ON public.global_table (transaction_id);

-- the table to store BranchSession data
Expand Down Expand Up @@ -65,7 +65,4 @@ CREATE TABLE distributed_lock (
CONSTRAINT pk_distributed_lock_table PRIMARY KEY (lock_key)
);

INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('AsyncCommitting', ' ', 0);
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('RetryCommitting', ' ', 0);
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('RetryRollbacking', ' ', 0);
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('TxTimeoutCheck', ' ', 0);
INSERT INTO distributed_lock (lock_key, lock_value, expire) VALUES ('HandleAllSession', ' ', 0);
Original file line number Diff line number Diff line change
Expand Up @@ -26,44 +26,16 @@
@Component
@ConfigurationProperties(prefix = SERVER_RECOVERY_PREFIX)
public class ServerRecoveryProperties {
private Integer committingRetryPeriod = 1000;
private Integer asynCommittingRetryPeriod = 1000;
private Integer rollbackingRetryPeriod = 1000;
private Integer timeoutRetryPeriod = 1000;

public Integer getCommittingRetryPeriod() {
return committingRetryPeriod;
}

public ServerRecoveryProperties setCommittingRetryPeriod(Integer committingRetryPeriod) {
this.committingRetryPeriod = committingRetryPeriod;
return this;
}
private Integer handleAllSessionPeriod = 1000;

public Integer getAsynCommittingRetryPeriod() {
return asynCommittingRetryPeriod;
public Integer getHandleAllSessionPeriod() {
return handleAllSessionPeriod;
}

public ServerRecoveryProperties setAsynCommittingRetryPeriod(Integer asynCommittingRetryPeriod) {
this.asynCommittingRetryPeriod = asynCommittingRetryPeriod;
public ServerRecoveryProperties setHandleAllSessionPeriod(Integer handleAllSessionPeriod) {
this.handleAllSessionPeriod = handleAllSessionPeriod;
return this;
}

public Integer getRollbackingRetryPeriod() {
return rollbackingRetryPeriod;
}

public ServerRecoveryProperties setRollbackingRetryPeriod(Integer rollbackingRetryPeriod) {
this.rollbackingRetryPeriod = rollbackingRetryPeriod;
return this;
}

public Integer getTimeoutRetryPeriod() {
return timeoutRetryPeriod;
}

public ServerRecoveryProperties setTimeoutRetryPeriod(Integer timeoutRetryPeriod) {
this.timeoutRetryPeriod = timeoutRetryPeriod;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void testServerProperties() {

@Test
public void testServerRecoveryProperties() {
assertEquals(context.getBean(ServerRecoveryProperties.class).getAsynCommittingRetryPeriod(), 1000);
assertEquals(context.getBean(ServerRecoveryProperties.class).getHandleAllSessionPeriod(), 1000);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
*/
package io.seata.server.console.controller;

import javax.annotation.Resource;
import io.seata.server.console.service.BranchSessionService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
* Branch Session Controller
* @author: zhongxiang.wang
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public PageResult<GlobalSessionVO> query(GlobalSessionParam param) {
.filter(obtainPredicate(param))
.collect(Collectors.toList());

return PageResult.build(SessionConverter.convert(filteredSessions), param.getPageNum(), param.getPageSize());
return PageResult.build(SessionConverter.convertGlobalSession(filteredSessions), param.getPageNum(), param.getPageSize());
}


Expand Down
Loading

0 comments on commit e4ae6b7

Please sign in to comment.