dhiaayachi / temporal

Temporal service
https://docs.temporal.io
MIT License
0 stars 0 forks source link

Sending a RequestCancelActivityTask and a CancelTimer command with the last WFT causes UnhandledCommand error #421

Open dhiaayachi opened 2 months ago

dhiaayachi commented 2 months ago

Expected Behavior

Server accepts a WFT with RequestCancelActivityTask , CancelTimer, and CompleteWorkflowExecution.

Actual Behavior

server rejects the WFT with UnhandledCommand

Steps to Reproduce the Problem

Run this workflow

func UnhandledCommandRepro(ctx workflow.Context) error {
    ctx, cancelFunc := workflow.WithCancel(ctx)

    activityCtx := workflow.WithActivityOptions(ctx, workflow.ActivityOptions{
        ScheduleToStartTimeout: 10 * time.Second,
        ScheduleToCloseTimeout: 10 * time.Second,
        StartToCloseTimeout:    1 * time.Second,
        TaskQueue:              "bad_tq",
    })
    _ = workflow.ExecuteActivity(activityCtx, "Prefix_ToUpper", "hello")

    _ = workflow.NewTimer(ctx, 15*time.Second)

    err := workflow.NewTimer(ctx, time.Second).Get(ctx, nil)
    if err != nil {
        return err
    }
    cancelFunc()

    return nil
}

would expect the workflow to complete after the 1s timer, but the workflow will fail with UnhandledCommand error until the activity times out

Logs:

2023/03/12 22:16:50 DEBUG RequestCancelActivity Namespace integration-test-namespace TaskQueue tq-95c83b7a-d132-4d98-871f-a94c263f9995-TestIntegrationSuite/TestActivityGoRoutine WorkerID 92942@Quinn-Klassens-MacBook-Pro.local@ WorkflowType ActivityGoRoutine WorkflowID test-activity-go-routine RunID c9d8df17-2b6b-4e70-883f-1b033988e8bc Attempt 1 ActivityID 6
2023/03/12 22:16:50 DEBUG RequestCancelTimer Namespace integration-test-namespace TaskQueue tq-95c83b7a-d132-4d98-871f-a94c263f9995-TestIntegrationSuite/TestActivityGoRoutine WorkerID 92942@Quinn-Klassens-MacBook-Pro.local@ WorkflowType ActivityGoRoutine WorkflowID test-activity-go-routine RunID c9d8df17-2b6b-4e70-883f-1b033988e8bc Attempt 1 TimerID 7
2023/03/12 22:16:50 INFO  Activity B Failed. Namespace integration-test-namespace TaskQueue tq-95c83b7a-d132-4d98-871f-a94c263f9995-TestIntegrationSuite/TestActivityGoRoutine WorkerID 92942@Quinn-Klassens-MacBook-Pro.local@ WorkflowType ActivityGoRoutine WorkflowID test-activity-go-routine RunID c9d8df17-2b6b-4e70-883f-1b033988e8bc Attempt 1 Error canceled
RespondWorkflowTaskCompleted: &RespondWorkflowTaskCompletedRequest{TaskToken:[10 36 57 55 55 51 99 102 52 51 45 56 49 52 54 45 52 56 49 53 45 97 49 53 98 45 55 102 98 57 53 49 100 55 101 101 54 57 18 24 116 101 115 116 45 97 99 116 105 118 105 116 121 45 103 111 45 114 111 117 116 105 110 101 26 36 99 57 100 56 100 102 49 55 45 50 98 54 98 45 52 101 55 48 45 56 56 51 102 45 49 98 48 51 51 57 56 56 101 56 98 99 32 15 40 184 1 74 8 8 3 16 226 133 65 24 1],Commands:[]*Command{&v19.Command{CommandType:RequestCancelActivityTask,Attributes:&Command_RequestCancelActivityTaskCommandAttributes{RequestCancelActivityTaskCommandAttributes:&RequestCancelActivityTaskCommandAttributes{ScheduledEventId:6,},},},&v19.Command{CommandType:CancelTimer,Attributes:&Command_CancelTimerCommandAttributes{CancelTimerCommandAttributes:&CancelTimerCommandAttributes{TimerId:7,},},},&v19.Command{CommandType:CompleteWorkflowExecution,Attributes:&Command_CompleteWorkflowExecutionCommandAttributes{CompleteWorkflowExecutionCommandAttributes:&CompleteWorkflowExecutionCommandAttributes{Result:&v1.Payloads{Payloads:[]*Payload{&Payload{Metadata:map[string][]byte{encoding: [106 115 111 110 47 112 108 97 105 110],},Data:[91 34 116 111 85 112 112 101 114 87 105 116 104 68 101 108 97 121 34 93],},},},},},},},Identity:92942@Quinn-Klassens-MacBook-Pro.local@,StickyAttributes:&v14.StickyExecutionAttributes{WorkerTaskQueue:&TaskQueue{Name:Quinn-Klassens-MacBook-Pro.local:b2495e99-d2b2-463a-911c-6b48df951a93,Kind:Sticky,},ScheduleToStartTimeout:5s,},ReturnNewWorkflowTask:true,ForceCreateNewWorkflowTask:false,BinaryChecksum:38d48a2e8786064284cc875a9c7acf3f,QueryResults:map[string]*v17.WorkflowQueryResult{},Namespace:integration-test-namespace,WorkerVersioningId:nil,Messages:[]*Message{},SdkMetadata:&v110.WorkflowTaskCompletedMetadata{CoreUsedFlags:[],LangUsedFlags:[],},MeteringMetadata:&v13.MeteringMetadata{NonfirstLocalActivityExecutionAttempts:0,},}
2023/03/12 22:16:50 INFO  Task processing failed with error Namespace integration-test-namespace TaskQueue tq-95c83b7a-d132-4d98-871f-a94c263f9995-TestIntegrationSuite/TestActivityGoRoutine WorkerID 92942@Quinn-Klassens-MacBook-Pro.local@ WorkerType WorkflowWorker Error UnhandledCommand

Specifications