This is an automated email from the ASF dual-hosted git repository.
thunguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-seata-go.git
The following commit(s) were added to refs/heads/master by this push:
new 59807414 fix(grpc): use the correct message type for global commit
requests (#1166)
59807414 is described below
commit 598074146bc4142dd33f29d5d2a2049c90ba0f6f
Author: XiaoFei <[email protected]>
AuthorDate: Thu Sep 17 00:58:45 2026 +0800
fix(grpc): use the correct message type for global commit requests (#1166)
* fix(grpc): use the correct message type for global commit requests
* fix: ensure commit request is sent and update dev notes
---------
Co-authored-by: ThunGuo <[email protected]>
---
changes/dev.md | 1 +
pkg/tm/transaction/grpc/grpc_global_transaction.go | 2 +-
.../grpc/grpc_global_transaction_test.go | 31 ++++++++++++++++++++++
3 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/changes/dev.md b/changes/dev.md
index 156ebed5..a4590bbf 100755
--- a/changes/dev.md
+++ b/changes/dev.md
@@ -32,6 +32,7 @@
### bugfix:
+ - [[#1165](https://github.com/apache/incubator-seata-go/issues/1165)] fix
incorrect gRPC global commit request message type
- [[#904](https://github.com/apache/incubator-seata-go/issues/904)] fix
"busy buffer" / "driver: bad connection" when a `SELECT ... FOR UPDATE` is
followed by another statement under XA autoCommit, by deferring the branch
commit (XA END + XA PREPARE) until the query rows are closed
- [[#130](https://github.com/apache/incubator-seata-go/pull/130)] getty
session auto close bug
- [[#991](https://github.com/apache/incubator-seata-go/issues/991)] fix
connection leaks and prevent nil pointer panic in async worker
diff --git a/pkg/tm/transaction/grpc/grpc_global_transaction.go
b/pkg/tm/transaction/grpc/grpc_global_transaction.go
index e99ecb71..46c96b03 100644
--- a/pkg/tm/transaction/grpc/grpc_global_transaction.go
+++ b/pkg/tm/transaction/grpc/grpc_global_transaction.go
@@ -87,7 +87,7 @@ func (g *GrpcGlobalTransactionManager) Commit(ctx
context.Context, gtr *tm.Globa
req := &pb.GlobalCommitRequestProto{
AbstractGlobalEndRequest: &pb.AbstractGlobalEndRequestProto{
AbstractTransactionRequest:
&pb.AbstractTransactionRequestProto{
- AbstractMessage:
&pb.AbstractMessageProto{MessageType: pb.MessageTypeProto_TYPE_GLOBAL_BEGIN},
+ AbstractMessage:
&pb.AbstractMessageProto{MessageType: pb.MessageTypeProto_TYPE_GLOBAL_COMMIT},
},
Xid: gtr.Xid,
},
diff --git a/pkg/tm/transaction/grpc/grpc_global_transaction_test.go
b/pkg/tm/transaction/grpc/grpc_global_transaction_test.go
index 3b5d0c71..3190b98e 100644
--- a/pkg/tm/transaction/grpc/grpc_global_transaction_test.go
+++ b/pkg/tm/transaction/grpc/grpc_global_transaction_test.go
@@ -238,6 +238,37 @@ func TestGrpcGlobalTransactionCommit(t *testing.T) {
}
}
+func TestGrpcGlobalTransactionCommitSendsGlobalCommitMessageType(t *testing.T)
{
+ tm.SetGlobalTransactionManager(&grpc2.GrpcGlobalTransactionManager{})
+ tm.InitTm(tm.TmConfig{CommitRetryCount: 1})
+
+ called := false
+ patches :=
gomonkey.ApplyMethod(reflect.TypeOf(grpc.GetGrpcRemotingClient()),
"SendSyncRequest",
+ func(_ *grpc.GrpcRemotingClient, msg interface{}) (interface{},
error) {
+ called = true
+ req, ok := msg.(*pb.GlobalCommitRequestProto)
+ assert.True(t, ok)
+ assert.Equal(t, pb.MessageTypeProto_TYPE_GLOBAL_COMMIT,
+
req.GetAbstractGlobalEndRequest().GetAbstractTransactionRequest().GetAbstractMessage().GetMessageType())
+
+ return &pb.GlobalCommitResponseProto{
+ AbstractGlobalEndResponse:
&pb.AbstractGlobalEndResponseProto{
+ AbstractTransactionResponse:
&pb.AbstractTransactionResponseProto{
+ AbstractResultMessage:
&pb.AbstractResultMessageProto{
+ AbstractMessage:
&pb.AbstractMessageProto{MessageType:
pb.MessageTypeProto_TYPE_GLOBAL_COMMIT_RESULT},
+ },
+ },
+ GlobalStatus:
pb.GlobalStatusProto_Committed,
+ },
+ }, nil
+ })
+ defer patches.Reset()
+
+ gtr := &tm.GlobalTransaction{TxRole: tm.Launcher, Xid: "test-xid"}
+ assert.NoError(t,
tm.GetGlobalTransactionManager().Commit(context.Background(), gtr))
+ assert.True(t, called, "Commit should call SendSyncRequest")
+}
+
func TestGrpcGlobalTransactionRollback(t *testing.T) {
tm.SetGlobalTransactionManager(&grpc2.GrpcGlobalTransactionManager{})
tm.InitTm(tm.TmConfig{
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]