Clear StartedClock on activity retry#10232
Merged
Merged
Conversation
StartedClock is a per-attempt field set in RecordActivityTaskStarted and used to reconstruct the task token matching sent to the worker. It was not being cleared in UpdateActivityInfoForRetries or the paused-activity retry path, leaving a stale value during retry backoff. This caused cancel commands (#9233) to be dispatched for activities not currently running on any worker. Clear StartedClock alongside the other per-attempt fields (StartedEventId, StartedTime, StartVersion) and update the cancel command skip log message to reflect that nil StartedClock can mean retry backoff, not just pre-deploy. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verify that StartedClock, StartedTime, and StartedEventId are all cleared when an activity is retried. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Two additional paths reset per-attempt fields when an activity is paused (timer executor and RecordActivityTaskStarted) but were also missing the StartedClock clear. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Centralize the per-attempt field reset into a single exported function in the workflow package. All four call sites (normal retry, paused retry, timer executor pause, RecordActivityTaskStarted pause) now call this helper instead of duplicating the field assignments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verify that all per-attempt fields are cleared and non-started fields are left untouched. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
yycptt
approved these changes
May 12, 2026
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.
What
Clear
StartedClockon activity retry/pause. To do this, refactored the code that clears per attempt field into a singleClearActivityStartedStatehelper, and updated all code paths.Why
StartedClockis a per-attempt field introduced in #9233 to reconstruct task tokens for cancel worker commands. It was not being cleared when the activity leaves the started state (retry or pause), leaving a stale value during backoff. This can cause cancel commands to be unnecessarily dispatched for activities not currently running on any worker.How did you test it?
🤖 Generated with Claude Code