Skip to content

feat(workflow): add exponential backoff support#573

Open
conan8737 wants to merge 5 commits intodtm-labs:mainfrom
conan8737:feature/workflow_exponential_backoff
Open

feat(workflow): add exponential backoff support#573
conan8737 wants to merge 5 commits intodtm-labs:mainfrom
conan8737:feature/workflow_exponential_backoff

Conversation

@conan8737
Copy link
Copy Markdown

This PR implements exponential backoff support for workflows. The core logic follows the same pattern as the existing saga transaction handler, as referenced in issue #572.

@yedf2
Copy link
Copy Markdown
Contributor

yedf2 commented Jan 3, 2026

@conan8737 there is test failure. Can you fix it?

@conan8737
Copy link
Copy Markdown
Author

@yedf2 please try again

I can't reproduce this issue because I don't have a local MySQL environment, so I tested it on Redis instead. I suspect it's a problem with this piece of code, so I deleted it.

if err == nil && (time.Since(t.lastTouched)+NowForwardDuration >= 1500*time.Millisecond ||
		t.NextCronInterval > conf.RetryInterval && t.NextCronInterval > t.RetryInterval) {
		t.touchCronTime(cronReset, 0)
}

Because for Workflow, this is the end of the entire transaction (maybe one of the sub-transactions encountered an error), while in Saga, each sub-transaction is processed individually, so I thik this logic is unnecessary for Workflow.

@conan8737
Copy link
Copy Markdown
Author

conan8737 commented Jan 27, 2026

@yedf2 please try again
I have figured out what's going on. When a transaction rollback, query_prepared returns a Failure error, and exponential backoff should not be applied in this case. So I added a condition to check for this error.
else if err != nil && !errors.Is(err, dtmimp.ErrFailure)

redis

if old ~= ARGV[5] then

sql

dbGet().Must().Model(global).Where("status=? and gid=?", global.Status, global.Gid).

boltdb

if g == nil || g.Gid != global.Gid {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants