Skip to content

automatic time-skipping#9617

Open
feiyang3cat wants to merge 7 commits intotemporalio:mainfrom
feiyang3cat:server-time-skipping-v2
Open

automatic time-skipping#9617
feiyang3cat wants to merge 7 commits intotemporalio:mainfrom
feiyang3cat:server-time-skipping-v2

Conversation

@feiyang3cat
Copy link
Contributor

@feiyang3cat feiyang3cat commented Mar 23, 2026

What changed?

add automatic time-skipping, i.e. all features, unit-tests, feature tests are in this pr.
manual skipping, fine-grained control, chasm related not yet included.

1. full control plane related:
- dc flag for the feature in a namespace
- opt-in to enable time-skipping when starting a workflow
- disable/enable time-skipping with workflowUpdateOptions
- API related:

1. ExecuteMultiOperationRequest
2. StartWorkflowExecution
3. SignalWithStartWorkflowExecution
4. UpdateWorkflowExecutionOption
5. BatchOperationUpdateWorkflowExecutionOptions
6. PostResetOperation
7. ExecuteMultiOperationRequest

2. data plane:
- on mutation/snapshot a timeskipping transfer task is created with the transaction
- handling of time-skipping transfer-task: transaction (calculate time to be skipped, update virtual time of the ms, generate new timertasks with new virtual time)
- timeSkippingTimeSourceImpl and mutableState vitualTime
- mutableState rebuild

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)

@feiyang3cat feiyang3cat requested review from a team as code owners March 23, 2026 05:22
@feiyang3cat feiyang3cat changed the title [server-poc] automatic time-skipping [server-poc] automatic time-skipping (don't merge) Mar 23, 2026
@feiyang3cat
Copy link
Contributor Author

todo found: rebuild ms

@feiyang3cat feiyang3cat force-pushed the server-time-skipping-v2 branch from 1e69592 to 8f8fae8 Compare March 23, 2026 05:48
@feiyang3cat
Copy link
Contributor Author

currently, ts transfer task is using timer-task (setting time = now), can migrate to immediate transfer task.

@feiyang3cat feiyang3cat force-pushed the server-time-skipping-v2 branch from 8f8fae8 to 6eacb02 Compare March 24, 2026 00:05
@feiyang3cat feiyang3cat requested a review from a team as a code owner March 24, 2026 00:05
@feiyang3cat feiyang3cat force-pushed the server-time-skipping-v2 branch 8 times, most recently from 2463097 to 39ac713 Compare March 24, 2026 06:23
mutableState.approximateSize += dbRecord.ExecutionInfo.Size() - mutableState.executionInfo.Size()
mutableState.executionInfo = dbRecord.ExecutionInfo

if mutableState.executionInfo.GetTimeSkippingInfo().GetEnabled() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

bug

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

}
for _, task := range ms.InsertTasks[tasks.CategoryTimer] {
if userTimerTask, ok := task.(*tasks.UserTimerTask); ok {
userTimerTask.VisibilityTimestamp = userTimerTask.VisibilityTimestamp.Add(-skippedDuration)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

bug

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@feiyang3cat feiyang3cat force-pushed the server-time-skipping-v2 branch from 39ac713 to 2e1df0a Compare March 24, 2026 07:09
@feiyang3cat feiyang3cat force-pushed the server-time-skipping-v2 branch from 2e1df0a to dd0297a Compare March 24, 2026 07:13
@feiyang3cat feiyang3cat changed the title [server-poc] automatic time-skipping (don't merge) automatic time-skipping (don't merge) Mar 24, 2026
@feiyang3cat
Copy link
Contributor Author

should merge API first and change api-go commitID
temporalio/api#740

@feiyang3cat feiyang3cat changed the title automatic time-skipping (don't merge) automatic time-skipping Mar 24, 2026
AddWorkflowExecutionTimeSkippedEvent(ctx context.Context, advanceToTimePoint time.Time) (*historypb.HistoryEvent, error)
ApplyWorkflowExecutionTimeSkippedEvent(ctx context.Context, event *historypb.HistoryEvent) error
IsAutoTimeSkippable() bool
VirtualTimeNow() time.Time
Copy link
Contributor Author

Choose a reason for hiding this comment

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

can just call it now, if there is no timeskipping ever happened, return shard.Now()

"go.temporal.io/server/service/history/tasks"
)

type (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yux0 this time-skipping feature is almost completed in this pr, and I think replication will naturally be covered by this change? (I haven't add feature testing for replication yet, will need to read a bit on how to do that

@feiyang3cat
Copy link
Contributor Author

need to add more in-repo feature testing (now the basic uses cases are contained, edgy cases are needed)

add timeSkippingEvent to workflow rebuilder
fix bugs of taskRefersher, and mutable virtual time

The proto source had the api-linter suppression comment for to_time but
the generated .pb.go was not updated to reflect it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@feiyang3cat feiyang3cat force-pushed the server-time-skipping-v2 branch from dd0297a to 824d0c6 Compare March 24, 2026 07:24
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.

1 participant