Browse Source

Merge pull request #276 from dtm-labs/alpha

fix TimeoutToFail compensate
pull/281/head
yedf2 4 years ago
committed by GitHub
parent
commit
3e16acd482
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      dtmsvr/trans_type_saga.go
  2. 1
      test/saga_options_test.go

5
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

1
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) {

Loading…
Cancel
Save