Code Monkey home page Code Monkey logo

Comments (21)

dk-lockdown avatar dk-lockdown commented on September 3, 2024

@Leadrive config.yaml 这个错误我晚点更新下。branch_transaction 在 at 模式下用不到,tcc 模式下需要用来做幂等性校验,防悬挂等,但框架没有提供自动写这张表,需要业务来写。订单回滚失败有日志吗,贴一下

from incubator-seata-go.

Leadrive avatar Leadrive commented on September 3, 2024

我把order和product改了一下,就是直接执行一条简单的SQL
这是aggregation的log

begin CreateSo
{"Req":[{"sysNo":0,"soID":"","buyerUserSysNo":10001,"sellerCompanyCode":"SC001","receiveDivisionSysNo":110105,"receiveAddress":"朝阳区长安街001号","receiveZip":"000001","receiveContact":"斯密达","receiveContactPhone":"18728828296","stockSysNo":1,"paymentType":1,"soAmt":430.5,"status":10,"orderDate":"0001-01-01T00:00:00Z","paymentDate":"0001-01-01T00:00:00Z","deliveryDate":"0001-01-01T00:00:00Z","receiveDate":"0001-01-01T00:00:00Z","appID":"dk-order","memo":"","createUser":"","gmtCreate":"0001-01-01T00:00:00Z","modifyUser":"","gmtModified":"0001-01-01T00:00:00Z","SoItems":[{"sysNo":0,"soSysNo":0,"productSysNo":1,"productName":"刺力王","costPrice":200,"originalPrice":232,"dealPrice":215.25,"quantity":2}]}]}
{"Req":[{"ProductSysNo":1,"Qty":2}]}
INFO: 2021/09/19 08:49:43 [core] Subchannel Connectivity change to CONNECTING
INFO: 2021/09/19 08:49:43 [core] blockingPicker: the picked transport is not ready, loop back to repick
INFO: 2021/09/19 08:49:43 [core] pickfirstBalancer: UpdateSubConnState: 0xc0002cfc90, {CONNECTING <nil>}
INFO: 2021/09/19 08:49:43 [core] Channel Connectivity change to CONNECTING
INFO: 2021/09/19 08:49:43 [core] Subchannel picks a new address "localhost:8091" to connect
INFO: 2021/09/19 08:49:43 [transport] transport: loopyWriter.run returning. connection error: desc = "transport is closing"
INFO: 2021/09/19 08:49:43 [core] Subchannel Connectivity change to READY
INFO: 2021/09/19 08:49:43 [core] pickfirstBalancer: UpdateSubConnState: 0xc0002cfc90, {READY <nil>}
INFO: 2021/09/19 08:49:43 [core] Channel Connectivity change to READY
[GIN] 2021/09/19 - 08:49:43 | 200 |   12.4396676s |             ::1 | GET      "/createSoCommit"

这是order

begin createSo                                                                                                              
XID:aggregationSvc:9185685207973889                                                                                         
n:2, err:<nil>                                                                                                              
[GIN] 2021/09/19 - 08:49:31 | 200 |      8.3449ms |             ::1 | POST     "/createSo"                                  
INFO: 2021/09/19 08:49:31 [core] Subchannel Connectivity change to CONNECTING                                               
INFO: 2021/09/19 08:49:31 [core] pickfirstBalancer: UpdateSubConnState: 0xc0004ae110, {CONNECTING <nil>}                    
INFO: 2021/09/19 08:49:31 [core] Channel Connectivity change to CONNECTING                                                  
INFO: 2021/09/19 08:49:31 [core] Subchannel picks a new address "localhost:8091" to connect                                 
INFO: 2021/09/19 08:49:31 [core] Subchannel Connectivity change to READY                                                    
INFO: 2021/09/19 08:49:31 [core] pickfirstBalancer: UpdateSubConnState: 0xc0004ae110, {READY <nil>}                         
INFO: 2021/09/19 08:49:31 [core] Channel Connectivity change to READY                                                       
INFO: 2021/09/19 08:49:36 [transport] transport: loopyWriter.run returning. connection error: desc = "transport is closing" 
INFO: 2021/09/19 08:50:01 [core] Subchannel Connectivity change to CONNECTING                                               
INFO: 2021/09/19 08:50:01 [core] pickfirstBalancer: UpdateSubConnState: 0xc0004ae110, {CONNECTING <nil>}                    
INFO: 2021/09/19 08:50:01 [core] Channel Connectivity change to CONNECTING                                                  
INFO: 2021/09/19 08:50:01 [core] Subchannel picks a new address "localhost:8091" to connect                                 
INFO: 2021/09/19 08:50:01 [core] Subchannel Connectivity change to READY                                                    
INFO: 2021/09/19 08:50:01 [core] pickfirstBalancer: UpdateSubConnState: 0xc0004ae110, {READY <nil>}                         
INFO: 2021/09/19 08:50:01 [core] Channel Connectivity change to READY                                                       
INFO: 2021/09/19 08:50:06 [transport] transport: loopyWriter.run returning. connection error: desc = "transport is closing" 

这是product

begin AllocateInventory                                                                             
Error 1054: Unknown column 'value1' in 'field list'                                                 
[GIN] 2021/09/19 - 08:49:31 | 400 |     74.2957ms |             ::1 | POST     "/allocateInventory" 

from incubator-seata-go.

Leadrive avatar Leadrive commented on September 3, 2024

CreateSo函数,我取消了rollback bool,在里面,根据返回的err做判断

from incubator-seata-go.

dk-lockdown avatar dk-lockdown commented on September 3, 2024

@Leadrive seata-golang 日志文件的输出呢,类似

2021-09-19T08:57:50.896+0800	INFO	log/logging.go:157	xid aggregationSvc:9185693295489033 branch 9185693295489034, undo_log deleted with GlobalFinished

回滚失败这里会输出失败的原因。

from incubator-seata-go.

Leadrive avatar Leadrive commented on September 3, 2024

tc没报错

INFO: 2021/09/19 08:49:36 [transport] transport: closing server transport due to maximum connection age.
INFO: 2021/09/19 08:49:36 [transport] transport: loopyWriter.run returning. connection error: desc = "transport is closing"
WARNING: 2021/09/19 08:49:36 [transport] transport: http2Server.HandleStreams failed to read frame: read tcp [::1]:8091->[::1]:49647: use of closed network connection
INFO: 2021/09/19 08:49:36 [transport] transport: closing server transport due to maximum connection age.
INFO: 2021/09/19 08:49:36 [transport] transport: loopyWriter.run returning. connection error: desc = "transport is closing"
WARNING: 2021/09/19 08:49:36 [transport] transport: http2Server.HandleStreams failed to read frame: read tcp [::1]:8091->[::1]:49643: use of closed network connection
INFO: 2021/09/19 08:49:39 [transport] transport: closing server transport due to maximum connection age.
INFO: 2021/09/19 08:49:39 [transport] transport: loopyWriter.run returning. connection error: desc = "transport is closing"
WARNING: 2021/09/19 08:49:39 [transport] transport: http2Server.HandleStreams failed to read frame: read tcp [::1]:8091->[::1]:49648: use of closed network connection

from incubator-seata-go.

dk-lockdown avatar dk-lockdown commented on September 3, 2024

@Leadrive 订单服务有个日志输出到文件,这个日志文件的输出

from incubator-seata-go.

Leadrive avatar Leadrive commented on September 3, 2024

这是重新运行了一次

2021-09-19T09:25:24.535+0800	INFO	log/logging.go:157	successfully begin global transaction xid = {}%!(EXTRA string=aggregationSvc:9185700680949761)
2021-09-19T09:25:24.641+0800	INFO	log/logging.go:157	successfully rollback branch xid=%!d(string=aggregationSvc:9185700680949761) branchID=9185700680949762
2021-09-19T09:25:24.645+0800	INFO	log/logging.go:157	successfully rollback global, xid = %!d(string=aggregationSvc:9185700680949761)

from incubator-seata-go.

dk-lockdown avatar dk-lockdown commented on September 3, 2024

这是重新运行了一次

2021-09-19T09:25:24.535+0800	INFO	log/logging.go:157	successfully begin global transaction xid = {}%!(EXTRA string=aggregationSvc:9185700680949761)
2021-09-19T09:25:24.641+0800	INFO	log/logging.go:157	successfully rollback branch xid=%!d(string=aggregationSvc:9185700680949761) branchID=9185700680949762
2021-09-19T09:25:24.645+0800	INFO	log/logging.go:157	successfully rollback global, xid = %!d(string=aggregationSvc:9185700680949761)

回滚了嘛

from incubator-seata-go.

Leadrive avatar Leadrive commented on September 3, 2024
func (c *transactionManagerServiceClient) Rollback(ctx context.Context, in *GlobalRollbackRequest, opts ...grpc.CallOption) (*GlobalRollbackResponse, error) {
	out := new(GlobalRollbackResponse)
	err := c.cc.Invoke(ctx, "/apis.TransactionManagerService/Rollback", in, out, opts...)
	if err != nil {
		return nil, err
	}
	return out, nil
}

这里没报错,感觉应该是TC的问题。
我一会要出去了,要晚上才能看了。
我晚上再整理一个更简单的DEMO。

from incubator-seata-go.

Leadrive avatar Leadrive commented on September 3, 2024

undo_log中的记录还在。建议重点看看最后回滚操作那里。

from incubator-seata-go.

Leadrive avatar Leadrive commented on September 3, 2024
INSERT INTO `undo_log` (`id`, `branch_id`, `xid`, `context`, `rollback_info`, `log_status`, `log_created`, `log_modified`, `ext`) VALUES
	(1, 9185523456385075, 'aggregationSvc:9185523456385074', 'serializer=protobuf', _binary 0x5b5d, 1, '2021-09-19 01:00:53', '2021-09-19 01:00:53', NULL),
	(2, 9185523456385078, 'aggregationSvc:9185523456385077', 'serializer=protobuf', _binary 0x5b5d, 1, '2021-09-19 01:05:53', '2021-09-19 01:05:53', NULL),
	(3, 9185685207973890, 'aggregationSvc:9185685207973889', 'serializer=protobuf', _binary 0x5b5d, 1, '2021-09-19 08:49:43', '2021-09-19 08:49:43', NULL),
	(4, 9185700680949762, 'aggregationSvc:9185700680949761', 'serializer=protobuf', _binary 0x5b5d, 1, '2021-09-19 09:25:24', '2021-09-19 09:25:24', NULL);

这是表记录

from incubator-seata-go.

Leadrive avatar Leadrive commented on September 3, 2024

应该是直接执行SQL语句,undo_log中记录的rollback_info不完整,只有4个字节内容。
这个错误很容易重现的,在order中,改用SQL进行测试。
tx.Exec(INSERT INTO so1 SET value=RAND(10000)*10000)。
TC部分比较绕,我一时定位不到问题所在。麻烦作者抽时间完善下,谢谢!!

from incubator-seata-go.

Leadrive avatar Leadrive commented on September 3, 2024

刚才又试了。
r, err :=tx.Exec(INSERT INTO so1 (value) VALUES (?), "89232")
这种写法是可以的

r, err :=tx.Exec(`INSERT INTO so1 SET value=?`, "89232")

这种写法,记录写进去了,回滚失败,并且sql模块报panic

r, err :=tx.Exec(`INSERT INTO so1 SET value='353243'`)

这种写法,记录写进去了,回滚失败,不报panic

from incubator-seata-go.

dk-lockdown avatar dk-lockdown commented on September 3, 2024

@Leadrive 这个回滚有一些限制的,一定要有主键,INSERT INTO so1 SET value=RAND(10000)*10000,这个语句不支持。insert into values\update\delete。支持这几种语句,不能有子查询。

from incubator-seata-go.

Leadrive avatar Leadrive commented on September 3, 2024

@dk-lockdown 如果我想添加这部分支持,具体实现是在代码哪里?

from incubator-seata-go.

Leadrive avatar Leadrive commented on September 3, 2024

表都是有主键的,有AUTO ID。

from incubator-seata-go.

dk-lockdown avatar dk-lockdown commented on September 3, 2024

@dk-lockdown 如果我想添加这部分支持,具体实现是在代码哪里?
refer to statement.go func Exec(args []driver.Value) (driver.Result, error) and func Query(args []driver.Value) (driver.Rows, error)

from incubator-seata-go.

Leadrive avatar Leadrive commented on September 3, 2024

undo_log表中有记录,rollback_info中有内容,但是没做回滚操作。这个该如何定位错误呢?

2021-09-21T02:23:21.282+0800    DEBUG   log/logging.go:147      [implement] reflect.TypeOf: <*base.ProxyService Value>
2021-09-21T02:23:21.283+0800    DEBUG   log/logging.go:147      set method [XService]
2021-09-21T02:23:28.795+0800    DEBUG   log/logging.go:147      bind card:9186293416022020
2021-09-21T02:23:28.795+0800    INFO    log/logging.go:157      begin new global transaction [card:9186293416022020]
2021-09-21T02:23:28.859+0800    INFO    log/logging.go:157      [card:9186293416022020] rollback status: RolledBack
2021-09-21T02:23:28.859+0800    DEBUG   log/logging.go:147      unbind card:9186293416022020
2021-09-21T02:23:28.794+0800    INFO    log/logging.go:157      successfully begin global transaction xid = {}%!(EXTRA string=card:9186293416022020)
2021-09-21T02:23:28.859+0800    INFO    log/logging.go:157      successfully rollback global, xid = card:9186293416022020

from incubator-seata-go.

Leadrive avatar Leadrive commented on September 3, 2024

rollback_info内容是

0a15636172643a393138363239333431363032323032301a7d0801120660746573746022710a0660746573746012670a110a026964100122090800000000000000020a2d0a0675736572496418182221fe64316338646235396339313134616263613139303635633336646365326264640a230a08637265617465417418ba0122140b323032312d30392d32312030323a32333a3238

from incubator-seata-go.

Leadrive avatar Leadrive commented on September 3, 2024

这个是由于没有用SAMPLE中带的配置,只定义了new(Configuration())。
conf.ATConfig.LockRetryTimes=30
这个参数,如果不赋值,就导致上面不能回滚的问题。

另外,上面SQL语句写法导致的问题,都比较容易重现。

from incubator-seata-go.

dk-lockdown avatar dk-lockdown commented on September 3, 2024

这个值必须要有的

from incubator-seata-go.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.