[Fix-18540][Master] Reset the runtime state when recreating a failed task instance - #18541
Open
SEPURI-SAI-KRISHNA wants to merge 1 commit into
Open
[Fix-18540][Master] Reset the runtime state when recreating a failed task instance#18541SEPURI-SAI-KRISHNA wants to merge 1 commit into
SEPURI-SAI-KRISHNA wants to merge 1 commit into
Conversation
…task instance - Reset retryTimes so a recovered task gets its whole retry budget back - Clear startTime/endTime/pid/alertFlag inherited from the failed attempt - Add FailedRecoverTaskInstanceFactoryTest Closes apache#18540 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
SEPURI-SAI-KRISHNA
requested review from
SbloodyS,
caishunfeng and
ruanwenjun
as code owners
August 8, 2026 03:57
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 missing field resets were found and the fix and unit tests were drafted with AI
assistance (Claude Code); the behaviour, the comparison against the sibling factories and
the final code were reviewed and verified by me.
Purpose of the pull request
Closes #18540.
FailedRecoverTaskInstanceFactoryrecreates aFAILURE/KILLtask instance when aworkflow is recovered with "Recover failed tasks". It clones the old instance, clears part
of the runtime state and inserts it as a new row — but it never resets
retryTimes,startTime,endTime,pidoralertFlag, all of whichcloneTaskInstancecopies.Because a task that failed after exhausting its retries has
retryTimes == maxRetryTimes,and
TaskExecution#isTaskInstanceCanRetry()isretryTimes < maxRetryTimes, therecreated instance starts with a fully consumed retry budget and is never retried on the
recovery run, however many retries the task definition asks for.
The two sibling factories already do this correctly —
FirstRunTaskInstanceFactorysetsretryTimes(0),startTime(null),endTime(null),alertFlag(NO), andRetryTaskInstanceFactorysetsstartTime(null),endTime(null),pid(0)whiledeliberately incrementing
retryTimes. This change brings the recover factory in linewith them.
The stale
startTime/endTimeare user visible too: until the task actually starts, thenew instance is shown with the previous attempt's timestamps, and
TaskInstanceServiceImpl#queryTaskListPagingderives its duration from them.Brief change log
FailedRecoverTaskInstanceFactory#createTaskInstance: resetretryTimesto0andclear
startTime,endTime,pidandalertFlagon the recreated task instance.FailedRecoverTaskInstanceFactoryTest.Verify this pull request
This change added tests and can be verified as follows:
FailedRecoverTaskInstanceFactoryTestwith three cases: the retry budget isrestored, the runtime state of the failed attempt is cleared, and the origin instance is
still marked invalid while the new one is inserted.
./mvnw -pl dolphinscheduler-master -am clean test \ -Dtest=FailedRecoverTaskInstanceFactoryTest \ -Dsurefire.failIfNoSpecifiedTests=falseVerified locally:
devand pass with this change. Ondevthe recreated instancereports
retryTimes = 3where0is expected, and keeps thestartTimeof the failedattempt where
nullis expected.dolphinscheduler-mastersuite passes: 98 tests, 0 failures, 0 errors../mvnw -pl dolphinscheduler-master spotless:checkpasses.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