Skip to content

Fix FirstWorkflowTaskBackoff Accumulation upon ContinueAsNew - #11839

Merged
yycptt merged 3 commits into
temporalio:mainfrom
yycptt:fix-continue-as-new-backoff
Sep 1, 2026
Merged

yycptt merged 3 commits into
temporalio:mainfrom
yycptt:fix-continue-as-new-backoff

Conversation

@yycptt

@yycptt yycptt commented Aug 28, 2026

Copy link
Copy Markdown
Member

What changed?

  • Fix FirstWorkflowTaskBackoff Accumulation upon ContinueAsNew

Why?

  • Today if workflow continueAsNew before executionTime, the calculated lifetime will be negative and causing backoff to keep accumulating via continueAsNew.

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)

@yycptt
yycptt requested a review from a team August 28, 2026 00:10
@yycptt
yycptt requested review from a team as code owners August 28, 2026 00:10
@yycptt yycptt added the reliability-2026 Reliability related changes label Aug 28, 2026
Comment on lines +2979 to +2981
lifetime := max(time.Duration(0), now.Sub(ms.executionState.StartTime.AsTime().UTC()))
if ms.executionInfo.ExecutionTime != nil {
lifetime = ms.timeSource.Now().Sub(ms.executionInfo.ExecutionTime.AsTime().UTC())
executionLifetime := now.Sub(ms.executionInfo.ExecutionTime.AsTime().UTC())

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.

what is the definition of StartTime and ExecutionTime?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

StartTime is when mutable state record is created, ExecutionTime is when first workflow task is scheduled.

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.

I was wondering why it could be in the future. but it seems ExecutionTime is the planned time for the first workflow task, not the actual first workflow task schedule time.

@yycptt yycptt Sep 2, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

correct, that's planned time and update/signalWithStart today can bypass and schedule the first workflow task before that.

Comment on lines +2979 to +2981
lifetime := max(time.Duration(0), now.Sub(ms.executionState.StartTime.AsTime().UTC()))
if ms.executionInfo.ExecutionTime != nil {
lifetime = ms.timeSource.Now().Sub(ms.executionInfo.ExecutionTime.AsTime().UTC())
executionLifetime := now.Sub(ms.executionInfo.ExecutionTime.AsTime().UTC())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

StartTime is when mutable state record is created, ExecutionTime is when first workflow task is scheduled.

@yycptt
yycptt force-pushed the fix-continue-as-new-backoff branch from b126a5e to c06fcfc Compare September 1, 2026 17:16
@yycptt
yycptt merged commit be0318a into temporalio:main Sep 1, 2026
55 checks passed
@yycptt
yycptt deleted the fix-continue-as-new-backoff branch September 1, 2026 18:04
thestephenstanton pushed a commit that referenced this pull request Sep 2, 2026
## What changed?
- Fix FirstWorkflowTaskBackoff Accumulation upon ContinueAsNew

## Why?
- Today if workflow continueAsNew before executionTime, the calculated
lifetime will be negative and causing backoff to keep accumulating via
continueAsNew.

## How did you test it?
- [x] built
- [ ] run locally and tested manually
- [ ] covered by existing tests
- [x] added new unit test(s)
- [x] added new functional test(s)
awln-temporal added a commit that referenced this pull request Sep 3, 2026
## What changed?

Backports the remaining merged PRs labeled
[release/1.32.0](https://github.com/temporalio/temporal/issues?q=state%3Aclosed%20label%3Arelease%2F1.32.0)
onto release/v1.32.x, in main merge order:

- [#11599](#11599) Optimize
Visibility PostgreSQL upgrade schema v1.14
- [#11723](#11723) Validate
history pagination branch token against mutable state
- [#11800](#11800) Capture
panics in Visibility query converter
- [#11813](#11813) Capture
panic in ServiceErrorInterceptor
- [#11829](#11829) Return
empty Elasticsearch page token when the result is smaller than the page
- [#11839](#11839) Fix
FirstWorkflowTaskBackoff accumulation upon Continue-As-New
- [#11801](#11801) Fix
Visibility SQL query conversion

[#11265](#11265) and
[#11564](#11564) were already
present on release/v1.32.x and are not duplicated here.

## Testing

- Targeted unit tests for Visibility query conversion, RPC interception,
History branch-token validation, and Continue-As-New backoff
- make GOLANGCI_LINT_FIX=false
GOLANGCI_LINT_BASE_REV=origin/release/v1.32.x lint-code

---------

Co-authored-by: Rodrigo Zhou <[email protected]>
Co-authored-by: Prathyush PV <[email protected]>
Co-authored-by: Yichao Yang <[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.

4 participants