apache / incubator-seata-go Goto Github PK
View Code? Open in Web Editor NEWGo Implementation For Seata
Home Page: https://seata.apache.org/
License: Apache License 2.0
Go Implementation For Seata
Home Page: https://seata.apache.org/
License: Apache License 2.0
Hi @dk-lockdown ,
请问此处是因为性能原因的考虑,直接返回了true吗?还是说,这个方法还没有完整实现?
Describe the bug
branchID is bigint type in database, and int64 in seata-golang, but its type is defined string in BusinessActionContext
To Reproduce
No error to be reproduced. This is not a bug actually, just need to set BranchID to a correct type
Expected behavior
None
Additional context
None
AT模式下我没有找到分支执行BranchRegister和LockQuery 的具体地方, 只看到RM直接本地commit了(samples里的代码). 可以解答一下吗, 非常感谢
tc小错误:
TC中带的config.yml
globaltable: global_table2
branchtable: branch_table2
SQL脚本创建的表名不带2的。会导致进不了CreateSo方法。
在product中,故意写错误,在seata_order数据库中,undo_log表有记录,但是branch_transaction没有记录。
在global_transaction.go中的
status, err := gtx.transactionManager.Rollback(ctx, gtx.XID)
却没有报错。实际第一步的order操作回滚失败的。
请检查一下
问题1:请问数据层支持gorm吗或者改进后支持吗
问题2:例子里的三个服务是gin写的,go-micro如何接入
如题
The SAGA mode is driven by a state machine. In the Saga mode, each participant in the business process submits a local transaction. When a participant fails, it will compensate the previously successful participant. The first-stage forward service and the second-stage compensation service All are implemented by business developer. The Seata Java version already supports SAGA mode.
make seata-golang support saga mode.
High
Support describing state machine with state diagram.
Distributed transactions driven by the state machine to achieve final consistency.
Familiar with the Seata-Golang,and, understand the principle of SAGA mode.
SAGA 模式由状态机驱动,在Saga模式中,业务流程中每个参与者都提交本地事务,当出现某一个参与者失败则补偿前面已经成功的参与者,一阶段正向服务和二阶段补偿服务都由业务开发实现。Seata Java 版本已经支持 SAGA 模式。
使 Seata-Golang 支持 SAGA 模式。
高
支持用状态图描述状态机
由状态机驱动分布式事务达到最终一致性
熟悉 Seata-Golang 框架,了解 SAGA 模式的原理。
Welcome to use seata-go. To know who is using it, pls append your org info as follow,
Organization:Alibaba (Required)
Location: Hangzhou, Zhejiang, China(Required)
Contact: [[email protected]](mailto:[email protected]) (Optional)
Purpose:used as our fundamental transaction lib (Required)
Registry: zookeeper(Required)
Config: zookeeper(Required)
Version: 1.5.5(Required)
TransactionMode: AT\TCC\SAGA\XA
Com/Org Logo:(Optional)
Thanks again for your participation!
Thanks again for your participation!
欢迎使用 seata-go,首先感谢您的使用,其次您可以参考下面的样例来提供您的信息以收集使用场景:
* 组织:阿里巴巴(Required)
* 地点:**杭州(Required)
* 联系方式:[email protected](Optional)
* 场景:阿里内部服务化改造(Required)
* 注册中心: zookeeper(Optional)
* 配置中心: zookeeper(Optional)
* 版本: 1.5.5(Optional)
* 事务模式: AT\TCC\SAGA\XA
* 公司图标:(Optional)
Currently, the configuration of seata-golang is configured through yaml files. In the era of microservices, it is necessary to provide support for the registration center and configuration center.
Refer to dubbo-go to support nacos.
Low
Make seata-golang support registration to nacos and read configuration from nacos and etcd.
Make seata-golang client support reading configuration from nacos and etcd.
Familiar with the seata-golang,Familiar with the nacos and etcd.
当前,seata-golang 的配置通过 yaml 文件配置,在微服务时代,有必要对注册中心、配置中心提供支持。
参考 dubbo-go 支持 nacos、etcd。
低
使 seata-golang 支持注册到 nacos 、支持从 nacos、etcd 读取配置。
使 seata-golang client 支持从 nacos、etcd 读取配置。
熟悉 seata-golang,熟悉 nacos、etcd。
如题!
主要是方面入门,和学习
Describe the bug
//ok
tx.ExecContext(ctx, "UPDATE so_master SET memo=? WHERE 1=1 ", time.Now().Format("2006-01-02 15:04:05"))
//error :Branch lock acquire failed xid
tx.ExecContext(ctx, "INSERT INTO testinsert (id) values(?) ", time.Now().Format("2006-01-02 15:04:05"))
To Reproduce
package main
import (
"context"
"database/sql"
"fmt"
"time"
"github.com/opentrx/mysql"
"github.com/transaction-wg/seata-golang/pkg/client"
"github.com/transaction-wg/seata-golang/pkg/client/config"
seataContext "github.com/transaction-wg/seata-golang/pkg/client/context"
"github.com/transaction-wg/seata-golang/pkg/client/tm"
)
const configPath = "./conf/client.yml"
/**
DROP TABLE IF EXISTS `testinsert`;
CREATE TABLE `testinsert` (
`id` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
*/
func main() {
//r := gin.Default()
config.InitConf(configPath)
client.NewRpcClient()
mysql.InitDataResourceManager()
mysql.RegisterResource(config.GetATConfig().DSN)
sqlDB, err := sql.Open("mysql", config.GetATConfig().DSN)
if err != nil {
panic(err)
}
sqlDB.SetMaxOpenConns(100)
sqlDB.SetMaxIdleConns(20)
sqlDB.SetConnMaxLifetime(4 * time.Hour)
ctx := context.Background()
//获取seata的rootContext
rootContext := seataContext.NewRootContext(ctx)
//创建seata事务
seataTx := tm.GetCurrentOrCreate(rootContext)
seataTx.BeginWithTimeoutAndName(int32(6000000), "test", rootContext)
xid := rootContext.GetXID()
ctx = context.WithValue(ctx, "XID", xid)
tx, err := sqlDB.BeginTx(ctx, &sql.TxOptions{Isolation: sql.LevelDefault, ReadOnly: false})
if err != nil {
fmt.Println(err)
}
fmt.Println("XID:", xid)
//update 语句可以正常执行
//_, err = tx.ExecContext(ctx, "UPDATE so_master SET memo=? WHERE 1=1 ", time.Now().Format("2006-01-02 15:04:05"))
// insert 语句出现异常
_, err = tx.ExecContext(ctx, "INSERT INTO testinsert (id) values(?) ", time.Now().Format("2006-01-02 15:04:05"))
if err != nil {
fmt.Println(err)
}
err = tx.Commit()
if err != nil {
fmt.Println(err)
}
err = seataTx.Commit(rootContext)
if err != nil {
fmt.Println(err)
}
fmt.Println("--------end---")
}
Expected behavior
The insert statement is used normally
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
Thie is the pr
I want to try to participate in the contribution of Seata-golang. Thank you.
Is your feature request related to a problem? Please describe.
Currently, the TC server side is counting active TM to avoid querying clients that are off-line.
If RM and TM are using the same addressing
, then it's ok because if TM is alive, then RM is also alive.
But when the addressing of RM and TM are different, it may cause an issue that TM is alive but RM is dead.
In such scenario, the branch message that sent to client side will get timeout issue.
Describe the solution you'd like
I'd like to count the active RM instead of TM.
Describe alternatives you've considered
Additional context
有些不想把配置放在配置文件中,建议可以通过传递一个对象
编译运行cmd,再启动aggregation_svc下的服务,未发起任何请求的情况下,cpu占用率都飙升到100%
定位到问题代码行在这里:transaction_coordinator.go,请问是什么原因?
import (
"time"
)
import (
"github.com/dubbogo/getty"
"github.com/pkg/errors"
)
import (
"github.com/dk-lockdown/seata-golang/base/getty/config"
)
为什么把 import 的包通过多个 import 来拆分呢?我在其他开源项目里没看到过这种写法,如果写成通过空行来分组是不是更好一些?如下:
import (
"time"
"github.com/dubbogo/getty"
"github.com/pkg/errors"
"github.com/dk-lockdown/seata-golang/base/getty/config"
)
Is your feature request related to a problem? Please describe.
Currently, the IsRollingBackDead func is using fixed time config.
https://github.com/opentrx/seata-golang/blob/v2/pkg/tc/model/global_transaction.go#L55
Describe the solution you'd like
I want to add a new global config for it.
Describe alternatives you've considered
add new config in tc's config file.
Is your feature request related to a problem? Please describe.
Currently in TCC mode, the commit and rollback are in sync way. I'd like to make them async and able to be configurable.
Describe the solution you'd like
Make the TCC async commit and rollback way configurable
Describe alternatives you've considered
process TCC async commit and rollback in branch session
Additional context
TBD
dev 分支,从配置文件读取配置的代码(pkg\config\client_config.go)返回不了错误:
func InitConf(confFile string) error {
var err error //这里的err 是空的
if confFile == "" {
//这里包裹err的时候,因为err是空的,所以这里无法包裹消息
return errors.WithMessagef(err, fmt.Sprintf("application configure file name is nil"))
}
if path.Ext(confFile) != ".yml" {
//这里和上面是同样的错误
return errors.WithMessagef(err, fmt.Sprintf("application configure file name{%v} suffix must be .yml", confFile))
}
clientConfig = ClientConfig{}
confFileStream, err := ioutil.ReadFile(confFile)
if err != nil {
return errors.WithMessagef(err, fmt.Sprintf("ioutil.ReadFile(file:%s) = error:%s", confFile, err))
}
err = yaml.Unmarshal(confFileStream, &clientConfig)
if err != nil {
return errors.WithMessagef(err, fmt.Sprintf("yaml.Unmarshal() = error:%s", err))
}
(&clientConfig).GettyConfig.CheckValidity()
(&clientConfig).ATConfig.CheckValidity()
if clientConfig.ATConfig.DSN != "" {
cache.SetTableMetaCache(cache.NewMysqlTableMetaCache(clientConfig.ATConfig.DSN))
}
return nil
}
Is your feature request related to a problem? Please describe.
We want to deploy the tc server at kubernetes with a config file, which stays inside git. So the problem is we want to hide the config credentials, such as db password, username from git.
At this moment, the most important config we want to hide from config file is https://github.com/opentrx/seata-golang/blob/dev/cmd/profiles/dev/config.yml#L34
Describe the solution you'd like
When this config is initialized from file, add an env variable fallback, so we can deploy these db credentials from env.
Describe alternatives you've considered
Maybe config center in the @todo list of this project can solve this issue as well.
Additional context
nope
branch register err: TransactionException: branch lock acquire failed
建议加到256
Is your feature request related to a problem? Please describe.
I want to support configuration of struct type instead of yaml file, so that we can find missing config and config errors in go build
or go run main.go
step, which, will also make it easier to find configurations (in our IDE)
Describe the solution you'd like
I'd like to use .env
file and configurations of struct type to manage the configurations.
.env
example:
SERVER_PORT=8091
port := config.Cfg.Server.Port
Describe alternatives you've considered
Additional context
还有一个问题是,是否支持pgsql?需要自己扩展吗?
分布式事物由两个事物组成
1负责创建订单时扣减库存
2负责创建订单时写入订单主表和订单明细表
当1事物 commit 之后(库存减少了) , 2事物出错了需要回滚 , 全局回滚完成 之前, 这时读取的库存数是1事物commit之后的, 这种问题要怎么处理?
java端和go端相互调用的微服务,可以达到AT模式事务的效果吗?
// Len returns the number of items in a set.
func (s *Set) Len() int {
return len(s.List())
}
改成下面效率会更高
// Len returns the number of items in a set.
func (s *Set) Len() int {
s.RLock()
defer s.RUnlock()
return len(s.m)
}
Is your feature request related to a problem? Please describe.
Golint is deprecated by official golint
Describe the solution you'd like
how about use golangci-lint : golangci-lint
I'd like to update github action and create a pull-req to fix lint if any
Describe alternatives you've considered
作为go的seata server的作者,现在seata go server已经不维护了,协议只兼容到0.5.x版本,后面的协议大改版之后,就不支持了。
tc启动解析配置文件报错:配置文件config.yml中是sync_committing_retry_period,但json解析时写的是async_committing_retry_period。
executor.go中,如果UPDATE, DELETE操作没数据,beforeImage, afterImage将为nil。
有多处使用到的地方,会出现
runtime error: invalid memory address or nil pointer dereference
由于存在多次调用,我怕自己弄的有遗漏,没提PR,留待作者修改。
More and more people use the golang to develop microservices. The seata-golang distributed transaction framework already supports mysql database. Some companies use postgresql database and oracle database, so it is necessary to provide support for postgresql database and oracle database.
Refer to mysql driver to implement postgresql driver and oracle driver.
Medium
make seata-golang support postgresql.
make seata-golang support oracle.
achieve one of two.
Familiar with the mysql driver,understand the principle.
越来越多人使用 go 语言开发微服务,seata-golang 分布式事务已经支持 mysql 数据库,还有公司使用 postgresql 数据库、oracle 数据库,所以有必要对 postgresql 数据库、oracle 数据库也提供支持。
参考 mysql driver 实现 postgresql driver、oracle driver。
中
使 postgresql driver 集成 seata。
使 oracle driver 集成 seata。
二选一实现。
熟悉 mysql driver 的原理。
1 后期还有什么维护计划吗?
2 代码有更详细的文档说明吗?
分成两个版本的分支日后难以维护,是否存在通过接口屏蔽GRPC和Getty的差异,用户可以通过配置切换
Summer 2021
is a program hosted by ISCAS(Institute of Software Chinese Academy of Sciences) and openEuler community. It is very similar with Google Summer of Code.
Seata will join The Summer 2021 as the mentoring organization.
Home page, https://summer.iscas.ac.cn
Seata community will choose some challenging topics, so that more college students can participate in the open source community and learn more about Seata. At the same time, the Seata community will gain more new contributors.
. At the same time, Seata community will obtain more new contributors.
Topic list:
“开源之夏2021”是由ISCAS(**科学院软件研究所)和openEuler社区托管的程序。 与Google Summer of Code非常相似。
Seata 将会作为指导组织参加本次的“开源之夏2021”。
“开源之夏2021”的官方网站为:https://summer.iscas.ac.cn
Seata 将选择一些具有挑战性的主题,让更多的高校学生参与到开源社区和了解Seata的更多信息。 同时,Seata 社区将获得更多新的贡献者。
主题列表如下:
最新版本,mariadb最新版本。
2022-03-02T09:20:33.737+0800 ERROR log/logging.go:178 exception committing branch xid=%!d(string=stock:9243734585778180) branchID=9243734585778182, err: driver: bad connection
2022-03-02T09:20:33.737+0800 ERROR log/logging.go:178 failed to async committing [stock:9243734585778180]
2022-03-02T09:20:33.746+0800 ERROR log/logging.go:178 exception committing branch xid=%!d(string=stock:9243734585778184) branchID=9243734585778186, err: there is no resource manager for AT
2022-03-02T09:20:33.746+0800 ERROR log/logging.go:178 failed to async committing [stock:9243734585778184]
2022-03-02T09:20:33.757+0800 ERROR log/logging.go:178 exception committing branch xid=%!d(string=common:9243734585778187) branchID=9243734585778189, err: driver: bad connection
2022-03-02T09:20:33.757+0800 ERROR log/logging.go:178 failed to async committing [common:9243734585778187]
2022-03-02T09:20:33.761+0800 INFO log/logging.go:158 global[%!d(string=stock:9243734585778192)] committing is successfully done.
2022-03-02T09:20:33.765+0800 INFO log/logging.go:158 global[%!d(string=stock:9243734585778193)] committing is successfully done.
2022-03-02T09:20:43.774+0800 ERROR log/logging.go:178 exception committing branch xid=%!d(string=stock:9243734585778180) branchID=9243734585778183, err: there is no resource manager for AT
2022-03-02T09:20:43.774+0800 ERROR log/logging.go:178 failed to async committing [stock:9243734585778180]
2022-03-02T09:20:43.787+0800 INFO log/logging.go:158 global[%!d(string=stock:9243734585778184)] committing is successfully done.
2022-03-02T09:20:43.787+0800 ERROR log/logging.go:178 exception committing branch xid=%!d(string=common:9243734585778187) branchID=9243734585778189, err: there is no resource manager for AT
2022-03-02T09:20:43.787+0800 ERROR log/logging.go:178 failed to async committing [common:9243734585778187]
2022-03-02T09:20:53.803+0800 INFO log/logging.go:158 global[%!d(string=stock:9243734585778180)] committing is successfully done.
2022-03-02T09:20:53.803+0800 ERROR log/logging.go:178 exception committing branch xid=%!d(string=common:9243734585778187) branchID=9243734585778189, err: there is no resource manager for AT
2022-03-02T09:20:53.803+0800 ERROR log/logging.go:178 failed to async committing [common:9243734585778187]
2022-03-02T09:21:03.829+0800 INFO log/logging.go:158 global[%!d(string=common:9243734585778187)] committing is successfully done.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.