From 316009ff17e17f9ef7667f18ca0ac010360c9987 Mon Sep 17 00:00:00 2001 From: yedf2 <120050102@qq.com> Date: Thu, 21 Apr 2022 11:55:54 +0800 Subject: [PATCH] fix TimeoutToFail compensate --- dtmsvr/trans_type_saga.go | 5 ++++- test/saga_options_test.go | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/dtmsvr/trans_type_saga.go b/dtmsvr/trans_type_saga.go index 2e3ddab..763d714 100644 --- a/dtmsvr/trans_type_saga.go +++ b/dtmsvr/trans_type_saga.go @@ -187,7 +187,10 @@ func (t *transSagaProcessor) ProcessOnce(branches []TransBranch) error { } } prepareToCompensate := func() { - _ = pickToRunActions() // flag started + toRun := pickToRunActions() + for _, b := range toRun { // flag started + branchResults[b].started = true + } for i := 1; i < len(branchResults); i += 2 { // these branches may have run. so flag them to status succeed, then run the corresponding // compensate diff --git a/test/saga_options_test.go b/test/saga_options_test.go index 879a440..6134ee7 100644 --- a/test/saga_options_test.go +++ b/test/saga_options_test.go @@ -55,6 +55,7 @@ func TestSagaOptionsTimeout(t *testing.T) { assert.Equal(t, StatusSubmitted, getTransStatus(saga.Gid)) cronTransOnceForwardNow(t, gid, 3600) assert.Equal(t, StatusFailed, getTransStatus(saga.Gid)) + assert.Equal(t, []string{StatusSucceed, StatusPrepared, StatusPrepared, StatusPrepared}, getBranchesStatus(saga.Gid)) } func TestSagaGlobalTransWithRequestTimeout(t *testing.T) {