Skip to content

Fix activity timeout regeneration after unpause - #11666

Merged
fretz12 merged 4 commits into
mainfrom
fredtzeng/wfa-unpause-clear-timer
Aug 20, 2026
Merged

fretz12 merged 4 commits into
mainfrom
fredtzeng/wfa-unpause-clear-timer

Conversation

@fretz12

@fretz12 fretz12 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

What changed?

  • Clear an activity’s timer-task status when it is unpaused so timeout tasks are regenerated.
  • Make ResetActivity with keepPaused=false fully unpause both scheduled and running activities, including clearing pause metadata.
  • Add and strengthen unit and functional coverage for unpause, reset-unpause, timer regeneration, and keepPaused=true.

Why?

Timeout tasks can fire while an activity is paused and be discarded. Previously, the activity’s timer-task status still indicated that those tasks existed, preventing them from being recreated after unpause and potentially making the timeout ineffective.
ResetActivity also bypassed normal unpause handling, and running activities returned early without clearing their paused state.

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

Unpausing now invalidates existing timeout tasks and recreates the next applicable timer during transaction close. This is correct, but a behavioral change. Stale queued tasks may still be processed and discarded through the existing stamp validation.

@fretz12
fretz12 requested review from a team, dandavison and spkane31 August 19, 2026 23:04
@fretz12
fretz12 requested review from a team as code owners August 19, 2026 23:04
@fretz12 fretz12 added the reliability-2026 Reliability related changes label Aug 19, 2026
@github-actions

github-actions Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Claude encountered an error after 2m 58s —— View job


I'll analyze this and get back to you.

@github-actions

github-actions Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @fretz12's task in 7m 18s —— View job


Reviewed 3 files, 4 findings.
· fredtzeng/wfa-unpause-clear-timer

Comment thread service/history/workflow/activity.go Resolved
Comment thread service/history/workflow/activity.go Resolved
Comment thread tests/activity_api_reset_test.go Resolved
err = ResetActivity(context.Background(), s.mockShard, s.mutableState, ai.ActivityId,
false, true, false, 0)
s.NoError(err)
s.Require().NoError(err)

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.

Why did this change to s.Require()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Intentional, AGENTS.md guidance requires s.Require().NoError(err) for errors in testify suites. And I think we want to stop the test if it fails here right? s.NoError will continue rolling

ID: s.tv.WorkflowID(),
TaskQueue: s.TaskQueue(),
}, workflowFn)
s.Require().NoError(err)

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.

Can these be s.NoError(err)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

same as above

s.Equal(int32(1), startedActivityCount.Load())
}

func (s *ActivityApiResetClientTestSuite) TestActivityResetApi_UnpausesRunningActivity() {

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.

If an activity is paused longer than the StartToClose timeout it will transition directly to TIMEOUT after being unpaused, I think we should codify this behavior with a test

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added

// Timer tasks can be dropped while paused without clearing this mask. Clear all
// bits so transaction close recreates the earliest timer. This can create duplicate
// timer tasks, but after one processes the timeout, the others become no-ops.
ai.TimerTaskStatus = TimerTaskStatusNone

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.

Should all of the timer tasks be dropped or only the timer tasks whose deadline has already passed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. Clearing only expired bits would avoid recreating future timer tasks. Clearing all is still correctness-safe: transaction close recreates the earliest timer, and timeout processing is idempotent, so duplicates become no-ops. Since pause-time deadline handling will be reworked for WFA/SAA parity, I’d prefer to keep this fix minimal rather than add temporary deadline-selection logic.

@fretz12
fretz12 marked this pull request as draft August 20, 2026 18:13
@fretz12
fretz12 marked this pull request as ready for review August 20, 2026 18:14
@github-actions

github-actions Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @fretz12's task in 5m 51s —— View job


Reviewed 3 files, 5 findings.
· fredtzeng/wfa-unpause-clear-timer

Comment thread tests/activity_api_reset_test.go Resolved
Comment thread tests/activity_api_reset_test.go Resolved
Comment thread tests/activity_api_reset_test.go Resolved
Comment on lines +373 to +377
timerTaskStatus := int32(TimerTaskStatusCreatedScheduleToClose |
TimerTaskStatusCreatedScheduleToStart |
TimerTaskStatusCreatedStartToClose |
TimerTaskStatusCreatedHeartbeat)
ai.TimerTaskStatus = timerTaskStatus

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.

nit — The same four-bit mask is spelled out five times.

Repeated at lines 373, 410, 447, 478, and 508. TimerTaskStatusCreatedPerAttempt | TimerTaskStatusCreatedScheduleToClose is the identical value in one line, and it ties the tests to the constant the production code reasons about (timer_sequence.go:39).

Suggestion: Apply the same collapse at the other four sites.

Suggested change
timerTaskStatus := int32(TimerTaskStatusCreatedScheduleToClose |
TimerTaskStatusCreatedScheduleToStart |
TimerTaskStatusCreatedStartToClose |
TimerTaskStatusCreatedHeartbeat)
ai.TimerTaskStatus = timerTaskStatus
timerTaskStatus := int32(TimerTaskStatusCreatedPerAttempt | TimerTaskStatusCreatedScheduleToClose)
ai.TimerTaskStatus = timerTaskStatus

Comment thread service/history/workflow/activity.go Resolved
@fretz12
fretz12 merged commit abeeabd into main Aug 20, 2026
54 checks passed
@fretz12
fretz12 deleted the fredtzeng/wfa-unpause-clear-timer branch August 20, 2026 18:43
davidporter-id-au pushed a commit to davidporter-id-au/temporal that referenced this pull request Aug 24, 2026
## What changed?
- Clear an activity’s timer-task status when it is unpaused so timeout
tasks are regenerated.
- Make ResetActivity with keepPaused=false fully unpause both scheduled
and running activities, including clearing pause metadata.
- Add and strengthen unit and functional coverage for unpause,
reset-unpause, timer regeneration, and keepPaused=true.

## Why?
Timeout tasks can fire while an activity is paused and be discarded.
Previously, the activity’s timer-task status still indicated that those
tasks existed, preventing them from being recreated after unpause and
potentially making the timeout ineffective.
ResetActivity also bypassed normal unpause handling, and running
activities returned early without clearing their paused state.

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

## Potential risks
Unpausing now invalidates existing timeout tasks and recreates the next
applicable timer during transaction close. This is correct, but a
behavioral change. Stale queued tasks may still be processed and
discarded through the existing stamp validation.
@awln-temporal awln-temporal mentioned this pull request Sep 4, 2026
5 tasks done
simvlad pushed a commit that referenced this pull request Sep 4, 2026
## What changed?
- Clear an activity’s timer-task status when it is unpaused so timeout
tasks are regenerated.
- Make ResetActivity with keepPaused=false fully unpause both scheduled
and running activities, including clearing pause metadata.
- Add and strengthen unit and functional coverage for unpause,
reset-unpause, timer regeneration, and keepPaused=true.

## Why?
Timeout tasks can fire while an activity is paused and be discarded.
Previously, the activity’s timer-task status still indicated that those
tasks existed, preventing them from being recreated after unpause and
potentially making the timeout ineffective.
ResetActivity also bypassed normal unpause handling, and running
activities returned early without clearing their paused state.

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

## Potential risks
Unpausing now invalidates existing timeout tasks and recreates the next
applicable timer during transaction close. This is correct, but a
behavioral change. Stale queued tasks may still be processed and
discarded through the existing stamp validation.

(cherry picked from commit abeeabd)
simvlad added a commit that referenced this pull request Sep 4, 2026
## What changed?

Backports the 12 merged PRs labeled
[release/1.32.0](https://github.com/temporalio/temporal/issues?q=repo%3Atemporalio%2Ftemporal+is%3Apr+label%3Arelease%2F1.32.0)
that were not yet on `release/v1.32.x`, applied in `main` merge order.
Also fixes mixedbrain test by bumping go version to 1.26.8 in mixedbrain
folder (broken by #11928).

| # | PR | Author | What / Why |
|---|----|--------|------------|
| 1 | [#11546](#11546)
fix(batcher): scope deterministic request IDs to the batch job ID |
@spkane31 | Two batch operations sending the same signal to the same
workflow/run ID only delivered one — the request ID was hashed from
workflow ID / run ID / signal name, so the second was de-duped in signal
logic. Including the batch job ID in the hash keeps separate signals
distinct. |
| 2 | [#11642](#11642) Fix
batch operations targeting paused executions | @fretz12 | A paused
execution is still non-terminal, but the old `Running`-only filter
silently skipped paused targets. Users issuing a batch
terminate/signal/cancel reasonably expect it to apply to them. |
| 3 | [#11666](#11666) Fix
activity timeout regeneration after unpause | @fretz12 | Timeout tasks
that fired while an activity was paused were discarded, but the
activity's timer-task status still claimed they existed — preventing
recreation after unpause and potentially making the timeout ineffective.
Also fixes `ResetActivity` bypassing normal unpause handling, and
running activities returning early without clearing paused state. |
| 4 | [#11696](#11696) Treat
missing Worker Deployment Version as deleted | @rkannan82 | Treats
`NotFound` from the Version workflow delete update as success. When a
Version workflow is already closed or its history is gone, `NotFound`
blocked the Deployment workflow from removing its stale version
reference. Fixes #11539. |
| 5 | [#11725](#11725) Fix
batch activity unpause visibility query scope | @fretz12 | The server
replaced the caller's visibility query with the activity-type predicate,
which could broaden the batch scope and unpause activities in workflows
the caller never selected. |
| 6 | [#11806](#11806) Fix
activity operator command metric label collision | @fretz12 | WFA and
SAA emitted the same Prometheus metric names
(`activity_pause`/`unpause`/`reset`/`update_options`) with **different
label sets**, causing descriptor registration failures and dropped
metrics. Both now use the standard per-activity label schema and emit
once per affected activity. **See "Backport adaptation" below.** |
| 7 | [#11930](#11930)
Prioritize worker versioning workflows | @ShahabT | Worker versioning
workflows share the per-namespace worker task queue with other system
workflows. Raising their initial workflow-task priority above default
keeps versioning operations from queueing behind default-priority work.
|
| 8 | [#11910](#11910)
[Visibility] Fix legacy visibility query converter | @rodrigozhou |
Fixes to the legacy visibility query converter for both SQL and
Elasticsearch. |
| 9 | [#11699](#11699)
dynamic partitioning: use probability of AddTask to root partition to
estimate overall add task rate | @carlydf | A previous PR changed
AddTask load-balancing from uniform random to backlog-aware,
invalidating the uniform-distribution assumption behind the
add-task-rate estimate. Now estimates from the probability of AddTask
hitting the root partition, and guarantees the root retains at least a
1% chance of selection regardless of its backlog. |
| 10 | [#11935](#11935)
[Visibility] Enable unified query converter by default | @rodrigozhou |
Flips the default now that the unified query converter is stable and
ready to replace the old one. Depends on #11910 and #11801. |

## How did you test it?

- [x] built — `go build ./...`
- [x] `make fmt` — no changes
- [x] `go vet -tags disable_grpc_modules,test_dep ./tests/...` — clean
- [x] `make GOLANGCI_LINT_FIX=false
GOLANGCI_LINT_BASE_REV=origin/release/v1.32.x lint-code` — **0 issues**
- [x] covered by existing tests — 21 affected packages, **20 pass**

---------

Co-authored-by: Sean Kane <[email protected]>
Co-authored-by: Fred Tzeng <[email protected]>
Co-authored-by: Kannan <[email protected]>
Co-authored-by: Shahab Tajik <[email protected]>
Co-authored-by: Rodrigo Zhou <[email protected]>
Co-authored-by: Carly de Frondeville <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Vladyslav Simonenko <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release/1.32.0 reliability-2026 Reliability related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants