Skip to content

remove reset_heartbeats field in ResetActivityExecutionRequest#10954

Open
spkane31 wants to merge 6 commits into
feature/activity-operator-cmdsfrom
spk/remove-keep-heartbeats
Open

remove reset_heartbeats field in ResetActivityExecutionRequest#10954
spkane31 wants to merge 6 commits into
feature/activity-operator-cmdsfrom
spk/remove-keep-heartbeats

Conversation

@spkane31

@spkane31 spkane31 commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

What changed?

Resetting an activity execution now always clears heartbeat details.

temporalio/api#820 Removes the reset_heartbeat field from the Request message.

Why?

This change simplifies the API surface and we (the engineering/product team) do not see a good use case for resetting an activity and keeping heartbeat data. If this is needed or there is a big customer ask for it we can add this back in the future.

How did you test it?

  • built
  • run locally and tested manually
  • covered by existing tests
  • added new unit test(s)
  • added new functional test(s)

Potential risks

Minimal, PR is into a feature branch

spkane31 and others added 4 commits July 1, 2026 14:14
Implements Pause, Unpause, Reset, and UpdateActivityExecutionOptions
RPCs for standalone CHASM activities. Adds matching frontend and
history service handlers in chasm/lib/activity that dispatch to
either the workflow-activity path or the standalone-activity path
based on the presence of a workflow ID.

Also adds PAUSE_REQUESTED and RESET_REQUESTED state machine states
for standalone activities, the original_options snapshot for
restore-on-reset semantics, the activity-options merge helpers
(common/activityoptions), and the supporting proto schema changes
(start_request_id, sdk_name, sdk_version, etc.).

Squash of the 29 commits previously on this branch. Original PRs:
  #9693  RPC boilerplate and code generation
  #9850  Implement UpdateActivityExecutionOptions
  #9851  Implement Pause/UnpauseActivityExecution for SAA
  #9852  Implement ResetActivityExecution for SAA
  #10001 Pause returns FailedPrecondition when already paused
  #10025 Validator function fixes
  #10265 Replace PauseState flag with PAUSE_REQUESTED state
  #10364 Add RESET_REQUESTED state to standalone activity
## What changed?
`start_delay` is now updatable via `UpdateActivityOptions` for
standalone activities. The new value is anchored to the original
`schedule_time`, so users can shorten it (including to 0, which
dispatches immediately if the target is already past), extend it, or
restore the original via `RestoreOriginal`. Updates once the activity
has left its delay window (first dispatch passed, or no longer
`SCHEDULED`) are rejected with `InvalidArgument`. The merge, validation,
and namespace dynamic-config check from activity creation are reused, so
create and update stay consistent.
  
This also adds the shared infrastructure for the downstream PRs:
- A persisted `first_attempt_started_time` on `ActivityState`, set once
on the first `SCHEDULED → STARTED` and never updated on retries/resets.
It is the canonical "has the first dispatch happened" discriminator.
- A `respectStartDelay` helper that lifts a candidate dispatch time to
`scheduleTime + start_delay` until first pickup, and no-ops afterward.
It drives `ActivityDispatchTask` re-issuance so an unrelated update in
the delay window no longer dispatches early, and gates the
`RestoreOriginal` restore so it never shows a stale value post-dispatch.
- Timer re-issuance split into `reissueRunningAttemptTimers`
(StartToClose/Heartbeat) and `reissueScheduledDispatch`
(Dispatch/ScheduleToStart).

Also changes a pre-existing behavior where the update path anchored
`ScheduleToClose` to `scheduleTime + timeout` instead of
`firstDispatchTime + timeout`; it now uses the canonical
`scheduleToCloseDeadline()`, matching `TransitionScheduled` and
`hasEnoughTimeForRetry`.

## Why?
Run-now (cancel-delay / kickstart) is table-stakes in the job queues SAA
is replacing (BullMQ, Sidekiq, Cloud Tasks, Asynq) and a GA
recommendation. Exposing `start_delay` through `UpdateActivityOptions`
covers both run-now (set 0) and rescheduling with one primitive, using
the same anchored-to-schedule-time semantics as creation. `start_delay`
is a first-attempt parameter, so `first_attempt_started_time` keeps
every re-scheduling path from re-applying or restoring it after
dispatch, where it would only mislead. The `ScheduleToClose` change
prevents an unrelated update during the delay window from shrinking the
deadline (sometimes into the past) and timing the activity out before it
dispatches.

## How did you test it?
- [X] built
- [X] run locally and tested manually
- [X] covered by existing tests
- [ ] added new unit test(s)
- [X] added new functional test(s)

---------

Co-authored-by: Dan Davison <dan.davison@temporal.io>
@spkane31 spkane31 requested review from a team as code owners July 7, 2026 19:27
@spkane31 spkane31 requested review from dandavison and fretz12 July 7, 2026 19:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR simplifies the activity reset API/behavior by making activity resets always clear heartbeat details, removing the now-unnecessary reset_heartbeats state, and updating state machine behavior and tests accordingly.

Changes:

  • Always clear stored heartbeat details on activity reset (including deferred reset application paths).
  • Remove reset_heartbeats from the CHASM ActivityState proto/state and delete associated state machine logic.
  • Update functional/unit tests to reflect the new “reset always clears heartbeat” semantics.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/activity_standalone_test.go Updates standalone reset tests to remove the reset-heartbeat toggle and assert heartbeat clearing as the default behavior.
chasm/lib/activity/statemachine.go Removes ResetHeartbeats state handling and makes deferred reset transitions always clear heartbeat state.
chasm/lib/activity/statemachine_test.go Replaces the old reset-flag tests with focused unit tests that verify heartbeat state is cleared on reset/deferred reset.
chasm/lib/activity/proto/v1/activity_state.proto Removes the reset_heartbeats field from persisted activity state.
chasm/lib/activity/handler.go Forces reset-heartbeat behavior on the workflow-path reset request (consistent with “always clear”).
chasm/lib/activity/gen/activitypb/v1/activity_state.pb.go Regenerated/updated protobuf output reflecting the removed field.
chasm/lib/activity/activity.go Makes reset paths unconditionally clear heartbeat state and removes now-unused request-driven branching.
Files not reviewed (1)
  • chasm/lib/activity/gen/activitypb/v1/activity_state.pb.go: Generated file

Comment thread chasm/lib/activity/statemachine_test.go Outdated
Comment thread chasm/lib/activity/statemachine_test.go
Comment thread chasm/lib/activity/statemachine_test.go
@@ -128,11 +128,6 @@ message ActivityState {
// metadata only.
ActivityPauseState last_pause_state = 16;
},
Activity: &workflowservice.ResetActivityRequest_Id{Id: frontendReq.GetActivityId()},
ResetHeartbeat: frontendReq.GetResetHeartbeat(),
ResetHeartbeat: true,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we should remove this from the proto as well since it's always true now?

@fretz12 fretz12 force-pushed the feature/activity-operator-cmds branch from 6d922e5 to 9ccc41b Compare July 10, 2026 17:31
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.

3 participants