|
62 | 62 | import io.temporal.internal.testservice.StateMachines.ActivityTaskData;
|
63 | 63 | import io.temporal.internal.testservice.StateMachines.CancelExternalData;
|
64 | 64 | import io.temporal.internal.testservice.StateMachines.ChildWorkflowData;
|
| 65 | +import io.temporal.internal.testservice.StateMachines.NexusOperationData; |
65 | 66 | import io.temporal.internal.testservice.StateMachines.SignalExternalData;
|
66 | 67 | import io.temporal.internal.testservice.StateMachines.State;
|
67 | 68 | import io.temporal.internal.testservice.StateMachines.TimerData;
|
@@ -782,14 +783,18 @@ private void processScheduleNexusOperation(
|
782 | 783 | nexusOperations.put(scheduleEventId, operation);
|
783 | 784 |
|
784 | 785 | operation.action(Action.INITIATE, ctx, attr, workflowTaskCompletedId);
|
| 786 | + // Record the current attempt of this request to be used in the timeout handler |
| 787 | + // of this request to make sure we are timing out the correct request. |
| 788 | + int attempt = operation.getData().getAttempt(); |
785 | 789 | ctx.addTimer(
|
786 | 790 | ProtobufTimeUtils.toJavaDuration(operation.getData().requestTimeout),
|
787 |
| - () -> |
788 |
| - timeoutNexusRequest( |
789 |
| - scheduleEventId, "StartNexusOperation", operation.getData().getAttempt()), |
| 791 | + () -> timeoutNexusRequest(scheduleEventId, "StartNexusOperation", attempt), |
790 | 792 | "StartNexusOperation request timeout");
|
791 | 793 | if (attr.hasScheduleToCloseTimeout()
|
792 | 794 | && Durations.toMillis(attr.getScheduleToCloseTimeout()) > 0) {
|
| 795 | + // ScheduleToCloseTimeout is the total time from the start of the operation to the end of the |
| 796 | + // operation |
| 797 | + // so the attempt is not relevant here. |
793 | 798 | ctx.addTimer(
|
794 | 799 | ProtobufTimeUtils.toJavaDuration(attr.getScheduleToCloseTimeout()),
|
795 | 800 | () ->
|
@@ -978,6 +983,7 @@ private void processScheduleActivityTask(
|
978 | 983 | ActivityTaskScheduledEventAttributes scheduledEvent =
|
979 | 984 | activityStateMachine.getData().scheduledEvent;
|
980 | 985 | int attempt = activityStateMachine.getData().getAttempt();
|
| 986 | + // TODO(quinn) If the first attempt fails, it is not clear this timer will work as expected |
981 | 987 | ctx.addTimer(
|
982 | 988 | ProtobufTimeUtils.toJavaDuration(scheduledEvent.getScheduleToCloseTimeout()),
|
983 | 989 | () ->
|
|
0 commit comments