diff --git a/dtmsvr/trans_type_saga.go b/dtmsvr/trans_type_saga.go index 15f8c6b..513190c 100644 --- a/dtmsvr/trans_type_saga.go +++ b/dtmsvr/trans_type_saga.go @@ -193,11 +193,13 @@ func (t *transSagaProcessor) ProcessOnce(branches []TransBranch) error { } } prepareToCompensate := func() { - toRunActions := pickToRunActions() - for _, b := range toRunActions { + _ = pickToRunActions() // flag started + for i := 1; i < len(branchResults); i += 2 { // these branches may have run. so flag them to status succeed, then run the corresponding // compensate - branchResults[b].status = dtmcli.StatusSucceed + if branchResults[i].started && branchResults[i].status == dtmcli.StatusPrepared { + branchResults[i].status = dtmcli.StatusSucceed + } } for i, b := range branchResults { if b.op == dtmcli.BranchCompensate && b.status != dtmcli.StatusSucceed &&