Skip to content

Clear StartedClock on activity retry#10232

Merged
rkannan82 merged 6 commits into
mainfrom
kannan/clear-started-clock-on-retry
May 13, 2026
Merged

Clear StartedClock on activity retry#10232
rkannan82 merged 6 commits into
mainfrom
kannan/clear-started-clock-on-retry

Conversation

@rkannan82
Copy link
Copy Markdown
Contributor

@rkannan82 rkannan82 commented May 12, 2026

What

Clear StartedClock on activity retry/pause. To do this, refactored the code that clears per attempt field into a single ClearActivityStartedState helper, and updated all code paths.

Why

StartedClock is 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?

  • Unit tests

🤖 Generated with Claude Code

rkannan82 and others added 5 commits May 12, 2026 13:12
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>
@rkannan82 rkannan82 requested a review from yycptt May 12, 2026 20:35
@rkannan82 rkannan82 marked this pull request as ready for review May 12, 2026 21:53
@rkannan82 rkannan82 requested review from a team as code owners May 12, 2026 21:53
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rkannan82 rkannan82 merged commit 81535bf into main May 13, 2026
47 checks passed
@rkannan82 rkannan82 deleted the kannan/clear-started-clock-on-retry branch May 13, 2026 00:14
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