This is an automated email from the ASF dual-hosted git repository.

flypiggy 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 f081d6ef fix: preserve distinct TCC fence log identities (#1079)
f081d6ef is described below

commit f081d6efc9ed650cc926476353380ca797267055
Author: CAICAII <[email protected]>
AuthorDate: Sat Mar 28 19:51:48 2026 +0800

    fix: preserve distinct TCC fence log identities (#1079)
---
 .../tcc/fence/handler/tcc_fence_wrapper_handler.go | 11 +++++++----
 .../handler/tcc_fence_wrapper_handler_test.go      | 23 ++++++++++++++++++++++
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/pkg/rm/tcc/fence/handler/tcc_fence_wrapper_handler.go 
b/pkg/rm/tcc/fence/handler/tcc_fence_wrapper_handler.go
index cee138eb..2a656591 100644
--- a/pkg/rm/tcc/fence/handler/tcc_fence_wrapper_handler.go
+++ b/pkg/rm/tcc/fence/handler/tcc_fence_wrapper_handler.go
@@ -212,10 +212,13 @@ func (handler *tccFenceWrapperHandler) 
initLogCleanTask(db *sql.DB) {
                        log.Errorf("failed to commit transaction: %v", err)
                }
 
-               // push to clean channel
-               for _, identity := range identityList {
-                       handler.logQueue <- &identity
-               }
+               handler.enqueueFenceLogIdentities(identityList)
+       }
+}
+
+func (handler *tccFenceWrapperHandler) enqueueFenceLogIdentities(identityList 
[]model.FenceLogIdentity) {
+       for i := range identityList {
+               handler.logQueue <- &identityList[i]
        }
 }
 
diff --git a/pkg/rm/tcc/fence/handler/tcc_fence_wrapper_handler_test.go 
b/pkg/rm/tcc/fence/handler/tcc_fence_wrapper_handler_test.go
index 7215dd4d..bc03f747 100644
--- a/pkg/rm/tcc/fence/handler/tcc_fence_wrapper_handler_test.go
+++ b/pkg/rm/tcc/fence/handler/tcc_fence_wrapper_handler_test.go
@@ -766,6 +766,29 @@ func TestPushCleanChannel(t *testing.T) {
        }
 }
 
+func TestEnqueueFenceLogIdentities_PreserveDistinctValues(t *testing.T) {
+       log.Init()
+
+       handler := &tccFenceWrapperHandler{
+               logQueue: make(chan *model.FenceLogIdentity, 3),
+       }
+       identities := []model.FenceLogIdentity{
+               {Xid: "xid1", BranchId: 1},
+               {Xid: "xid2", BranchId: 2},
+               {Xid: "xid3", BranchId: 3},
+       }
+
+       handler.enqueueFenceLogIdentities(identities)
+
+       consumed := []model.FenceLogIdentity{
+               *<-handler.logQueue,
+               *<-handler.logQueue,
+               *<-handler.logQueue,
+       }
+
+       assert.Equal(t, identities, consumed)
+}
+
 func TestPushCleanChannel_FullQueue(t *testing.T) {
        log.Init()
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to