[Fix-18538][Master] Schedule task retry at endTime + retryInterval - #18539
Open
SEPURI-SAI-KRISHNA wants to merge 1 commit into
Open
[Fix-18538][Master] Schedule task retry at endTime + retryInterval#18539SEPURI-SAI-KRISHNA wants to merge 1 commit into
SEPURI-SAI-KRISHNA wants to merge 1 commit into
Conversation
- Subtract the elapsed time since the task ended instead of adding it - Retry immediately when the retry interval has already passed - Add TaskRetryLifecycleEventTest covering both cases Closes apache#18538 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
SEPURI-SAI-KRISHNA
requested review from
SbloodyS,
caishunfeng and
ruanwenjun
as code owners
August 7, 2026 18:39
|
Thanks for opening this pull request! Please check out our contributing guidelines. (https://github.com/apache/dolphinscheduler/blob/dev/docs/docs/en/contribute/join/pull-request.md) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Was this PR generated or assisted by AI?
YES. The faulty expression was located and the fix and unit tests were drafted with AI
assistance (Claude Code); the reasoning, the failover impact analysis and the final code
were reviewed and verified by me.
Purpose of the pull request
Closes #18538.
TaskRetryLifecycleEvent#ofcomputes the delay before a failed task is retried. Theintent is to retry at
endTime + retryInterval, so the remaining delay isretryInterval - (now - endTime). The expression instead evaluated toretryInterval + (now - endTime)— the elapsed time was added rather than subtracted:In the common path
now - endTimeis a few milliseconds, so the error is invisible. Itmatters when the retry event is created long after the task actually ended — most
notably on master failover:
WorkflowFailoverCommandHandlerrebuilds the executiongraph from the existing task instances, so a task left in
FAILUREwith retriesremaining keeps its old
endTime;TaskFailureStateAction#onStartEventthen republishesthe failure event with that stale
endTime, and the retry gets postponed by the wholeoutage duration on top of the configured interval instead of firing immediately.
Brief change log
TaskRetryLifecycleEvent#of: subtract the elapsed time sinceendTimefrom the retryinterval, and clamp the result to
0so an already-overdue retry is triggeredimmediately.
delayTimetoretryInterval— it holds the configured retryinterval and shadowed the inherited
AbstractDelayEvent#delayTimefield, which is whatmade the wrong expression easy to miss.
TaskRetryLifecycleEventTest.Verify this pull request
This change added tests and can be verified as follows:
TaskRetryLifecycleEventTestwith three cases:endTimetwo hours in thepast) → the event is ready immediately. This case fails on
devwith a delay of~2h05m;
IllegalStateException, guarding the existingcheckState../mvnw -pl dolphinscheduler-master -am clean test \ -Dtest=TaskRetryLifecycleEventTest \ -Dsurefire.failIfNoSpecifiedTests=falseVerified locally:
devand pass with this change. Ondevthe failover case reportsa delay of
7499999ms (~2h05m) where0is expected, and the normal case reports330016ms where at most270000ms is expected.dolphinscheduler-mastersuite was run (98 tests). The only non-passing test wasWorkflowStartTimeoutTestCase#testStartWorkflow_withTimeoutWarnFailedTask, which isunrelated timing flakiness under the 4-way parallel forks: its fixture defines no
failRetryTimes, somaxRetryTimesis0,isTaskInstanceCanRetry()is false andTaskRetryLifecycleEvent#ofis never reached. The class passes 5/5 when re-run inisolation.
Pull Request Notice
Pull Request Notice
If your pull request contains incompatible change, you should also add it to
docs/docs/en/guide/upgrade/incompatible.md🤖 Generated with Claude Code