From 4624c05155f2f4d55b54121d42c1018f32180350 Mon Sep 17 00:00:00 2001 From: Jason Deng <76831112+jasondeng1997@users.noreply.github.com> Date: Sun, 7 May 2023 18:39:23 +0800 Subject: [PATCH] Merge branch 'seata:master' into master --- changes/1.1.1.md | 74 ++++++++ changes/1.1.1_zh.md | 78 ++++++++ pkg/datasource/sql/xa/mysql_xa_connection.go | 176 ------------------- 3 files changed, 152 insertions(+), 176 deletions(-) create mode 100644 changes/1.1.1.md create mode 100644 changes/1.1.1_zh.md delete mode 100644 pkg/datasource/sql/xa/mysql_xa_connection.go diff --git a/changes/1.1.1.md b/changes/1.1.1.md new file mode 100644 index 000000000..dd27a4f36 --- /dev/null +++ b/changes/1.1.1.md @@ -0,0 +1,74 @@ + + +### 1.1.1 + +
+ Release notes + +### Seata-go 1.1.1 + +Seata-go 1.1.1 Released. + +Seata-go is an easy-to-use, high-performance, open source distributed transaction solution. + +The version is updated as follows: + +### feature: + +- [[#534](https://github.com/seata/seata-go/pull/534)] add xid loadbalance +- [[#535](https://github.com/seata/seata-go/pull/535)] integrate test +- [[#536](https://github.com/seata/seata-go/pull/536)] fix go import +- [[#540](https://github.com/seata/seata-go/pull/540)] fix init panic +- [[#542](https://github.com/seata/seata-go/pull/542)] fix the conflict +- [[#545](https://github.com/seata/seata-go/pull/545)] fix get db version bug +- [[#547](https://github.com/seata/seata-go/pull/547)] fix xa start bug +- [[#548](https://github.com/seata/seata-go/pull/548)] feat: ✨ fix +### bugfix: + +- [[#532](https://github.com/seata/seata-go/pull/532)] fix: remove duplicate code + +### optimize: + +- [[#525](https://github.com/seata/seata-go/pull/456)] optimize(undo): change default parser name to json from jackson + +### test: + + +### doc: + + + +### contributors: + +Thanks to these contributors for their code commits. Please report an unintended omission. + +- [luky116](https://github.com/luky116) +- [georgehao](https://github.com/georgehao) +- [jasondeng1997](https://github.com/jasondeng1997) +- [106umao](https://github.com/106umao) +- [wang1309](https://github.com/wang1309) +- [iSuperCoder](https://github.com/iSuperCoder) +- [Charlie17Li](https://github.com/Charlie17Li) +- [Code-Fight](https://github.com/Code-Fight) +- [Kirhaku](https://github.com/Kirhaku) +- [Vaderkai](https://github.com/VaderKai) + + +Also, we receive many valuable issues, questions and advices from our community. Thanks all. + + \ No newline at end of file diff --git a/changes/1.1.1_zh.md b/changes/1.1.1_zh.md new file mode 100644 index 000000000..1cd108861 --- /dev/null +++ b/changes/1.1.1_zh.md @@ -0,0 +1,78 @@ + + +### 1.1.1 + +
+ Release notes + + ### Seata-go 1.1.1 + +Seata-go 1.1.1 发布。 + +Seata-go 是一款开源的分布式事务解决方案,提供高性能和简单易用的分布式事务服务。 + +此版本更新如下: + +### feature: +- [[#534](https://github.com/seata/seata-go/pull/534)] 支持 xid 负载均衡 +- [[#535](https://github.com/seata/seata-go/pull/535)] 集成测试 +- [[#536](https://github.com/seata/seata-go/pull/536)] 支持 go import +- [[#540](https://github.com/seata/seata-go/pull/540)] 支持修复 init 报错 +- [[#542](https://github.com/seata/seata-go/pull/542)] 修复冲突 +- [[#545](https://github.com/seata/seata-go/pull/545)] 支持 get db version 问题 +- [[#547](https://github.com/seata/seata-go/pull/547)] 支持修复 xa start 问题 +- [[#548](https://github.com/seata/seata-go/pull/548)] 支持修复xa start 空格问题 + + +### bugfix: +- [[#532](https://github.com/seata/seata-go/pull/532)] fix: remove duplicate code + +### optimize: + +- [[#525](https://github.com/seata/seata-go/pull/456)] optimize(undo): change default parser name to json from jackson + +### test: + + + +### doc: + + + +### contributors: + +非常感谢以下 contributors 的代码贡献。若有无意遗漏,请报告。 + +- [luky116](https://github.com/luky116) +- [georgehao](https://github.com/georgehao) +- [jasondeng1997](https://github.com/jasondeng1997) +- [106umao](https://github.com/106umao) +- [wang1309](https://github.com/wang1309) +- [iSuperCoder](https://github.com/iSuperCoder) +- [Charlie17Li](https://github.com/Charlie17Li) +- [Code-Fight](https://github.com/Code-Fight) +- [Kirhaku](https://github.com/Kirhaku) +- [Vaderkai](https://github.com/VaderKai) + + + + +同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。 + + + diff --git a/pkg/datasource/sql/xa/mysql_xa_connection.go b/pkg/datasource/sql/xa/mysql_xa_connection.go deleted file mode 100644 index 52c7fe132..000000000 --- a/pkg/datasource/sql/xa/mysql_xa_connection.go +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 xa - -import ( - "context" - "database/sql/driver" - "errors" - "fmt" - "io" - "strings" - "time" -) - -type MysqlXAConn struct { - driver.Conn -} - -func NewMysqlXaConn(conn driver.Conn) *MysqlXAConn { - return &MysqlXAConn{Conn: conn} -} - -func (c *MysqlXAConn) Commit(ctx context.Context, xid string, onePhase bool) error { - var sb strings.Builder - sb.WriteString("XA COMMIT ") - sb.WriteString(xid) - if onePhase { - sb.WriteString(" ONE PHASE") - } - - conn, _ := c.Conn.(driver.ExecerContext) - _, err := conn.ExecContext(ctx, sb.String(), nil) - return err -} - -func (c *MysqlXAConn) End(ctx context.Context, xid string, flags int) error { - var sb strings.Builder - sb.WriteString("XA END ") - sb.WriteString(xid) - - switch flags { - case TMSuccess: - break - case TMSuspend: - sb.WriteString(" SUSPEND") - break - case TMFail: - break - default: - return errors.New("invalid arguments") - } - - conn, _ := c.Conn.(driver.ExecerContext) - _, err := conn.ExecContext(ctx, sb.String(), nil) - return err -} - -func (c *MysqlXAConn) Forget(ctx context.Context, xid string) error { - // mysql doesn't support this - return errors.New("mysql doesn't support this") -} - -func (c *MysqlXAConn) GetTransactionTimeout() time.Duration { - return 0 -} - -// IsSameRM is called to determine if the resource manager instance represented by the target object -// is the same as the resource manager instance represented by the parameter xares. -func (c *MysqlXAConn) IsSameRM(ctx context.Context, xares XAResource) bool { - // todo: the fn depends on the driver.Conn, but it doesn't support - return false -} - -func (c *MysqlXAConn) XAPrepare(ctx context.Context, xid string) error { - var sb strings.Builder - sb.WriteString("XA PREPARE ") - sb.WriteString(xid) - - conn, _ := c.Conn.(driver.ExecerContext) - _, err := conn.ExecContext(ctx, sb.String(), nil) - return err -} - -// Recover Obtains a list of prepared transaction branches from a resource manager. -// The transaction manager calls this method during recovery to obtain the list of transaction branches -// that are currently in prepared or heuristically completed states. -func (c *MysqlXAConn) Recover(ctx context.Context, flag int) (xids []string, err error) { - startRscan := (flag & TMStartRScan) > 0 - endRscan := (flag & TMEndRScan) > 0 - - if !startRscan && !endRscan && flag != TMNoFlags { - return nil, errors.New("invalid arguments") - } - - if !startRscan { - return nil, nil - } - - conn := c.Conn.(driver.QueryerContext) - res, err := conn.QueryContext(ctx, "XA RECOVER", nil) - if err != nil { - return nil, err - } - - dest := make([]driver.Value, 4) - for true { - if err = res.Next(dest); err != nil { - if err == io.EOF { - return xids, nil - } - return nil, err - } - gtridAndbqual, ok := dest[3].(string) - if !ok { - return nil, errors.New("the protocol of XA RECOVER statement is error") - } - fmt.Printf("gtr: %v", gtridAndbqual) - - xids = append(xids, string(gtridAndbqual)) - } - return xids, err -} - -func (c *MysqlXAConn) Rollback(ctx context.Context, xid string) error { - var sb strings.Builder - sb.WriteString("XA ROLLBACK ") - sb.WriteString(xid) - - conn, _ := c.Conn.(driver.ExecerContext) - _, err := conn.ExecContext(ctx, sb.String(), nil) - return err -} - -func (c *MysqlXAConn) SetTransactionTimeout(duration time.Duration) bool { - return false -} - -func (c *MysqlXAConn) Start(ctx context.Context, xid string, flags int) error { - var sb strings.Builder - sb.WriteString("XA START") - sb.WriteString("'") - sb.WriteString(xid) - sb.WriteString("'") - - switch flags { - case TMJoin: - sb.WriteString(" JOIN") - break - case TMResume: - sb.WriteString(" RESUME") - break - case TMNoFlags: - break - default: - return errors.New("invalid arguments") - } - - conn, _ := c.Conn.(driver.ExecerContext) - _, err := conn.ExecContext(ctx, sb.String(), nil) - return err -}