tanzegen opened a new issue, #864:
URL: https://github.com/apache/incubator-seata-go/issues/864
<!-- Please use this template while reporting a bug and provide as much info
as possible. Not doing so may result in your bug not being addressed in a
timely manner. Thanks!
-->
**What happened**:
In nested transactions of tcc, transactions cannot be committed or rolled
back correctly.
**What you expected to happen**:
Transactions can be committed correctly or rolled back.
**How to reproduce it (as minimally and precisely as possible)**:
Run the following code:
```golang
func main() {
client.Init()
gtxConfig := &tm.GtxConfig{
Name: "FooGlobalTx",
}
ctx := context.Background()
err := tm.WithGlobalTx(ctx, gtxConfig, func(ctx context.Context) error {
subGtxConfig := &tm.GtxConfig{
Name: "FooSubGlobalTx",
}
return tm.WithGlobalTx(ctx, subGtxConfig, func(ctx
context.Context) error {
return nil
})
})
if err != nil {
panic(err)
}
}
```
You can see the following log output. The commit log of the sub-transaction
was printed twice. This indicates that when a sub-transaction is initiated, the
context of the outer transaction is overwritten by the inner one. This leads to
problems in the transaction level judgment, thus preventing the transaction
from being committed correctly.
```shell
2025-07-21 10:01:25.579 INFO getty/listener.go:64
Open new getty session
2025-07-21 10:01:25.589 INFO getty/getty_remoting.go:79
send async message: {message.RpcMessage{ID:2, Type:0x2, Codec:0x1,
Compressor:0x0
, HeadMap:map[string]string(nil),
Body:message.RegisterTMRequest{AbstractIdentifyRequest:message.AbstractIdentifyRequest{Version:"1.1.0",
ApplicationId:"applicationName", TransactionServiceGroup:"default_tx_group",
ExtraData:[]uint8(nil)}}}}
2025-07-21 10:01:25.592 INFO
client/client_on_response_processor.go:48 the rm client received
clientOnResponse msg message.RpcMessage{ID:2, Type:0x1, C
odec:0x1, Compressor:0x0, HeadMap:map[string]string{},
Body:message.RegisterTMResponse{AbstractIdentifyResponse:message.AbstractIdentifyResponse{AbstractResultMessage:message.AbstractResultMessage{ResultCode:0x0,
Msg:""}, Version:"1.5.0-SNAPSHOT", ExtraData:[]uint8(nil), Identified:true}}}
from tc server.
2025-07-21 10:01:25.677 INFO getty/getty_remoting.go:79
send async message: {message.RpcMessage{ID:1, Type:0x0, Codec:0x1,
Compressor:0x0, HeadMap:map[string]string(nil),
Body:message.GlobalBeginRequest{Timeout:60000000000,
TransactionName:"FooGlobalTx"}}}
2025-07-21 10:01:25.749 INFO
client/client_on_response_processor.go:48 the rm client received
clientOnResponse msg message.RpcMessage{ID:1, Type:0x1, C
odec:0x1, Compressor:0x0, HeadMap:map[string]string{},
Body:message.GlobalBeginResponse{AbstractTransactionResponse:message.AbstractTransactionResponse{AbstractResultMessage:message.AbstractResultMessage{ResultCode:0x1,
Msg:""}, TransactionErrorCode:0}, Xid:"10.42.20.213:8091:6197597443322783227",
ExtraData:[]uint8{}}} from tc server.
2025-07-21 10:01:25.749 INFO tm/global_transaction.go:66
GlobalBeginRequest success, res {{{1 } 0}
10.42.20.213:8091:6197597443322783227 []}
2025-07-21 10:01:25.750 INFO tm/transaction_executor.go:168
ignore second phase(commit or rollback): just involved in global
transaction [FooSubGlobalTx/10.42.20.213:8091:6197597443322783227]
2025-07-21 10:01:25.751 INFO tm/transaction_executor.go:168
ignore second phase(commit or rollback): just involved in global
transaction [FooSubGlobalTx/10.42.20.213:8091:6197597443322783227]
```
**Anything else we need to know?**:
This issue has been fixed and is awaiting approval for the merger.#848
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]