You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/06/28 15:43:55 UTC
[shardingsphere] branch master updated: Delete support for branch transaction on proxy (#18642)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 29f01ba3c11 Delete support for branch transaction on proxy (#18642)
29f01ba3c11 is described below
commit 29f01ba3c11265e1cb9b32560b8c477f9b53de64
Author: JingShang Lu <ji...@gmail.com>
AuthorDate: Tue Jun 28 23:43:48 2022 +0800
Delete support for branch transaction on proxy (#18642)
* Delete support for branch transaction on proxy
* keep TransactionXAHandler
---
.../features/transaction/use-norms/xa.cn.md | 99 --------------------
.../features/transaction/use-norms/xa.en.md | 100 ---------------------
.../transaction/core/TransactionType.java | 4 +-
.../session/transaction/TransactionStatus.java | 23 +----
.../text/transaction/TransactionXAHandler.java | 2 -
5 files changed, 3 insertions(+), 225 deletions(-)
diff --git a/docs/document/content/features/transaction/use-norms/xa.cn.md b/docs/document/content/features/transaction/use-norms/xa.cn.md
index c1f72bf63be..766ab3e4e17 100644
--- a/docs/document/content/features/transaction/use-norms/xa.cn.md
+++ b/docs/document/content/features/transaction/use-norms/xa.cn.md
@@ -16,102 +16,3 @@ weight = 2
* 服务宕机后,在其它机器上恢复提交/回滚中的数据;
* MySQL 事务块内,SQL 执行出现异常,执行 `Commit`,数据保持一致。
-
-## 通过 XA 语句控制的分布式事务
-* 通过 XA START 可以手动开启 XA 事务,注意该事务完全由用户管理,ShardingSphere 只负责将语句转发至后端数据库;
-* 服务宕机后,需要通过 XA RECOVER 获取未提交或回滚的事务,也可以在 COMMIT 时使用 ONE PHASE 跳过 PERPARE。
-
-```sql
-MySQL [(none)]> use test1 │MySQL [(none)]> use test2
-Reading table information for completion of table and column names │Reading table information for completion of table and column names
-You can turn off this feature to get a quicker startup with -A │You can turn off this feature to get a quicker startup with -A
- │
-Database changed │Database changed
-MySQL [test1]> XA START '61c052438d3eb'; │MySQL [test2]> XA START '61c0524390927';
-Query OK, 0 rows affected (0.030 sec) │Query OK, 0 rows affected (0.009 sec)
- │
-MySQL [test1]> update test set val = 'xatest1' where id = 1; │MySQL [test2]> update test set val = 'xatest2' where id = 1;
-Query OK, 1 row affected (0.077 sec) │Query OK, 1 row affected (0.010 sec)
- │
-MySQL [test1]> XA END '61c052438d3eb'; │MySQL [test2]> XA END '61c0524390927';
-Query OK, 0 rows affected (0.006 sec) │Query OK, 0 rows affected (0.008 sec)
- │
-MySQL [test1]> XA PREPARE '61c052438d3eb'; │MySQL [test2]> XA PREPARE '61c0524390927';
-Query OK, 0 rows affected (0.018 sec) │Query OK, 0 rows affected (0.011 sec)
- │
-MySQL [test1]> XA COMMIT '61c052438d3eb'; │MySQL [test2]> XA COMMIT '61c0524390927';
-Query OK, 0 rows affected (0.011 sec) │Query OK, 0 rows affected (0.018 sec)
- │
-MySQL [test1]> select * from test where id = 1; │MySQL [test2]> select * from test where id = 1;
-+----+---------+ │+----+---------+
-| id | val | │| id | val |
-+----+---------+ │+----+---------+
-| 1 | xatest1 | │| 1 | xatest2 |
-+----+---------+ │+----+---------+
-1 row in set (0.016 sec) │1 row in set (0.129 sec)
-
-MySQL [test1]> XA START '61c05243994c3'; │MySQL [test2]> XA START '61c052439bd7b';
-Query OK, 0 rows affected (0.047 sec) │Query OK, 0 rows affected (0.006 sec)
- │
-MySQL [test1]> update test set val = 'xarollback' where id = 1; │MySQL [test2]> update test set val = 'xarollback' where id = 1;
-Query OK, 1 row affected (0.175 sec) │Query OK, 1 row affected (0.008 sec)
- │
-MySQL [test1]> XA END '61c05243994c3'; │MySQL [test2]> XA END '61c052439bd7b';
-Query OK, 0 rows affected (0.007 sec) │Query OK, 0 rows affected (0.014 sec)
- │
-MySQL [test1]> XA PREPARE '61c05243994c3'; │MySQL [test2]> XA PREPARE '61c052439bd7b';
-Query OK, 0 rows affected (0.013 sec) │Query OK, 0 rows affected (0.019 sec)
- │
-MySQL [test1]> XA ROLLBACK '61c05243994c3'; │MySQL [test2]> XA ROLLBACK '61c052439bd7b';
-Query OK, 0 rows affected (0.010 sec) │Query OK, 0 rows affected (0.010 sec)
- │
-MySQL [test1]> select * from test where id = 1; │MySQL [test2]> select * from test where id = 1;
-+----+---------+ │+----+---------+
-| id | val | │| id | val |
-+----+---------+ │+----+---------+
-| 1 | xatest1 | │| 1 | xatest2 |
-+----+---------+ │+----+---------+
-1 row in set (0.009 sec) │1 row in set (0.083 sec)
-
-MySQL [test1]> XA START '61c052438d3eb';
-Query OK, 0 rows affected (0.030 sec)
-
-MySQL [test1]> update test set val = 'recover' where id = 1;
-Query OK, 1 row affected (0.072 sec)
-
-MySQL [test1]> select * from test where id = 1;
-+----+---------+
-| id | val |
-+----+---------+
-| 1 | recover |
-+----+---------+
-1 row in set (0.039 sec)
-
-MySQL [test1]> XA END '61c052438d3eb';
-Query OK, 0 rows affected (0.005 sec)
-
-MySQL [test1]> XA PREPARE '61c052438d3eb';
-Query OK, 0 rows affected (0.020 sec)
-
-MySQL [test1]> XA RECOVER;
-+----------+--------------+--------------+---------------+
-| formatID | gtrid_length | bqual_length | data |
-+----------+--------------+--------------+---------------+
-| 1 | 13 | 0 | 61c052438d3eb |
-+----------+--------------+--------------+---------------+
-1 row in set (0.010 sec)
-
-MySQL [test1]> XA RECOVER CONVERT XID;
-+----------+--------------+--------------+------------------------------+
-| formatID | gtrid_length | bqual_length | data |
-+----------+--------------+--------------+------------------------------+
-| 1 | 13 | 0 | 0x36316330353234333864336562 |
-+----------+--------------+--------------+------------------------------+
-1 row in set (0.011 sec)
-
-MySQL [test1]> XA COMMIT 0x36316330353234333864336562;
-Query OK, 0 rows affected (0.029 sec)
-
-MySQL [test1]> XA RECOVER;
-Empty set (0.011 sec)
-```
\ No newline at end of file
diff --git a/docs/document/content/features/transaction/use-norms/xa.en.md b/docs/document/content/features/transaction/use-norms/xa.en.md
index 6f7a496bf04..250fd1f26bd 100644
--- a/docs/document/content/features/transaction/use-norms/xa.en.md
+++ b/docs/document/content/features/transaction/use-norms/xa.en.md
@@ -16,103 +16,3 @@ weight = 2
* Recover committing and rolling back in other machines after the service is down;
* MySQL,in the transaction block, the SQL execution is abnormal, and run `Commit`, and data remains consistent.
-
-## XA Transaction managed by XA Statement
-
-* When using XA START to open a XA Transaction, ShardingSphere will pass it to backend database directly, you have to manage this transaction by yourself;
-* When recover from a crush, you have to call XA RECOVER to check unfinished transaction, and choose to commit or rollback using xid. Or you can use ONE PHASE commit without PREPARE.
-
-```sql
-MySQL [(none)]> use test1 │MySQL [(none)]> use test2
-Reading table information for completion of table and column names │Reading table information for completion of table and column names
-You can turn off this feature to get a quicker startup with -A │You can turn off this feature to get a quicker startup with -A
- │
-Database changed │Database changed
-MySQL [test1]> XA START '61c052438d3eb'; │MySQL [test2]> XA START '61c0524390927';
-Query OK, 0 rows affected (0.030 sec) │Query OK, 0 rows affected (0.009 sec)
- │
-MySQL [test1]> update test set val = 'xatest1' where id = 1; │MySQL [test2]> update test set val = 'xatest2' where id = 1;
-Query OK, 1 row affected (0.077 sec) │Query OK, 1 row affected (0.010 sec)
- │
-MySQL [test1]> XA END '61c052438d3eb'; │MySQL [test2]> XA END '61c0524390927';
-Query OK, 0 rows affected (0.006 sec) │Query OK, 0 rows affected (0.008 sec)
- │
-MySQL [test1]> XA PREPARE '61c052438d3eb'; │MySQL [test2]> XA PREPARE '61c0524390927';
-Query OK, 0 rows affected (0.018 sec) │Query OK, 0 rows affected (0.011 sec)
- │
-MySQL [test1]> XA COMMIT '61c052438d3eb'; │MySQL [test2]> XA COMMIT '61c0524390927';
-Query OK, 0 rows affected (0.011 sec) │Query OK, 0 rows affected (0.018 sec)
- │
-MySQL [test1]> select * from test where id = 1; │MySQL [test2]> select * from test where id = 1;
-+----+---------+ │+----+---------+
-| id | val | │| id | val |
-+----+---------+ │+----+---------+
-| 1 | xatest1 | │| 1 | xatest2 |
-+----+---------+ │+----+---------+
-1 row in set (0.016 sec) │1 row in set (0.129 sec)
-
-MySQL [test1]> XA START '61c05243994c3'; │MySQL [test2]> XA START '61c052439bd7b';
-Query OK, 0 rows affected (0.047 sec) │Query OK, 0 rows affected (0.006 sec)
- │
-MySQL [test1]> update test set val = 'xarollback' where id = 1; │MySQL [test2]> update test set val = 'xarollback' where id = 1;
-Query OK, 1 row affected (0.175 sec) │Query OK, 1 row affected (0.008 sec)
- │
-MySQL [test1]> XA END '61c05243994c3'; │MySQL [test2]> XA END '61c052439bd7b';
-Query OK, 0 rows affected (0.007 sec) │Query OK, 0 rows affected (0.014 sec)
- │
-MySQL [test1]> XA PREPARE '61c05243994c3'; │MySQL [test2]> XA PREPARE '61c052439bd7b';
-Query OK, 0 rows affected (0.013 sec) │Query OK, 0 rows affected (0.019 sec)
- │
-MySQL [test1]> XA ROLLBACK '61c05243994c3'; │MySQL [test2]> XA ROLLBACK '61c052439bd7b';
-Query OK, 0 rows affected (0.010 sec) │Query OK, 0 rows affected (0.010 sec)
- │
-MySQL [test1]> select * from test where id = 1; │MySQL [test2]> select * from test where id = 1;
-+----+---------+ │+----+---------+
-| id | val | │| id | val |
-+----+---------+ │+----+---------+
-| 1 | xatest1 | │| 1 | xatest2 |
-+----+---------+ │+----+---------+
-1 row in set (0.009 sec) │1 row in set (0.083 sec)
-
-MySQL [test1]> XA START '61c052438d3eb';
-Query OK, 0 rows affected (0.030 sec)
-
-MySQL [test1]> update test set val = 'recover' where id = 1;
-Query OK, 1 row affected (0.072 sec)
-
-MySQL [test1]> select * from test where id = 1;
-+----+---------+
-| id | val |
-+----+---------+
-| 1 | recover |
-+----+---------+
-1 row in set (0.039 sec)
-
-MySQL [test1]> XA END '61c052438d3eb';
-Query OK, 0 rows affected (0.005 sec)
-
-MySQL [test1]> XA PREPARE '61c052438d3eb';
-Query OK, 0 rows affected (0.020 sec)
-
-MySQL [test1]> XA RECOVER;
-+----------+--------------+--------------+---------------+
-| formatID | gtrid_length | bqual_length | data |
-+----------+--------------+--------------+---------------+
-| 1 | 13 | 0 | 61c052438d3eb |
-+----------+--------------+--------------+---------------+
-1 row in set (0.010 sec)
-
-MySQL [test1]> XA RECOVER CONVERT XID;
-+----------+--------------+--------------+------------------------------+
-| formatID | gtrid_length | bqual_length | data |
-+----------+--------------+--------------+------------------------------+
-| 1 | 13 | 0 | 0x36316330353234333864336562 |
-+----------+--------------+--------------+------------------------------+
-1 row in set (0.011 sec)
-
-MySQL [test1]> XA COMMIT 0x36316330353234333864336562;
-Query OK, 0 rows affected (0.029 sec)
-
-MySQL [test1]> XA RECOVER;
-Empty set (0.011 sec)
-```
\ No newline at end of file
diff --git a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/core/TransactionType.java b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/core/TransactionType.java
index 29f8c6d4ea4..c309097905d 100644
--- a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/core/TransactionType.java
+++ b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-core/src/main/java/org/apache/shardingsphere/transaction/core/TransactionType.java
@@ -22,7 +22,7 @@ package org.apache.shardingsphere.transaction.core;
*/
public enum TransactionType {
- LOCAL, XA, BASE, MANUALXA;
+ LOCAL, XA, BASE;
/**
* Judge whether distributed transaction.
@@ -31,6 +31,6 @@ public enum TransactionType {
* @return is distributed transaction or not
*/
public static boolean isDistributedTransaction(final TransactionType transactionType) {
- return XA == transactionType || BASE == transactionType || MANUALXA == transactionType;
+ return XA == transactionType || BASE == transactionType;
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/session/transaction/TransactionStatus.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/session/transaction/TransactionStatus.java
index 4b982331aee..7ae39287ea2 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/session/transaction/TransactionStatus.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/session/transaction/TransactionStatus.java
@@ -37,9 +37,6 @@ public final class TransactionStatus {
private volatile TransactionType transactionType;
- @Setter
- private volatile boolean manualXA;
-
@Setter
private volatile boolean rollbackOnly;
@@ -47,24 +44,6 @@ public final class TransactionStatus {
transactionType = initialTransactionType;
}
- /**
- * Get current transaction type of this session.
- *
- * @return MANUALXA when in manual xa transaction or predefined transaction type if not
- */
- public TransactionType getTransactionType() {
- return manualXA ? TransactionType.MANUALXA : transactionType;
- }
-
- /**
- * Check there's any transaction on this session.
- *
- * @return is in transaction or in manual xa transaction
- */
- public boolean isInTransaction() {
- return inTransaction || manualXA;
- }
-
/**
* Change transaction type of current channel.
*
@@ -83,6 +62,6 @@ public final class TransactionStatus {
* @return is in connection held transaction or not
*/
public boolean isInConnectionHeldTransaction() {
- return isInTransaction() && TransactionType.BASE != getTransactionType();
+ return inTransaction && TransactionType.BASE != transactionType;
}
}
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionXAHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionXAHandler.java
index b3ebbcee38a..98b4deb53c9 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionXAHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/transaction/TransactionXAHandler.java
@@ -75,7 +75,6 @@ public final class TransactionXAHandler implements TextProtocolBackendHandler {
}
ResponseHeader header = backendHandler.execute();
TransactionHolder.setInTransaction();
- connectionSession.getTransactionStatus().setManualXA(true);
return header;
case "END":
case "PREPARE":
@@ -86,7 +85,6 @@ public final class TransactionXAHandler implements TextProtocolBackendHandler {
try {
return backendHandler.execute();
} finally {
- connectionSession.getTransactionStatus().setManualXA(false);
TransactionHolder.clear();
FetchOrderByValueGroupsHolder.remove();
}