Skip to content

Commit 4edb110

Browse files
Remove unresolvedNexusCancelRequests
1 parent ef4de5d commit 4edb110

1 file changed

Lines changed: 3 additions & 23 deletions

File tree

temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableStateImpl.java

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ private interface UpdateProcedure {
107107
private final Map<Long, StateMachine<NexusOperationData>> nexusOperations = new HashMap<>();
108108
// Tracks cancelRequestedEventId by scheduledEventId, persists after operation removal.
109109
private final Map<Long, Long> nexusCancelRequestedEventIds = new HashMap<>();
110-
// Tracks scheduledEventIds of nexus cancel requests that have not yet received a response.
111-
private final Set<Long> unresolvedNexusCancelRequests = new HashSet<>();
112110
private final Map<String, StateMachine<TimerData>> timers = new HashMap<>();
113111
private final Map<String, StateMachine<SignalExternalData>> externalSignals = new HashMap<>();
114112
private final Map<String, StateMachine<CancelExternalData>> externalCancellations =
@@ -490,13 +488,10 @@ public void completeWorkflowTask(
490488
.asRuntimeException();
491489
}
492490

493-
if (unhandledCommand(request)
494-
|| unhandledMessages(request)
495-
|| hasUnresolvedNexusCancelWithCompletion(request)) {
491+
if (unhandledCommand(request) || unhandledMessages(request)) {
496492
// Fail the workflow task if there are new events or messages and a command tries to
497-
// complete the workflow, or if there are unresolved nexus cancel requests. Record the
498-
// failure in history, then throw an error to the caller (matching real server
499-
// behavior).
493+
// complete the workflow. Record the failure in history, then throw an error to the
494+
// caller (matching real server behavior).
500495
failWorkflowTaskWithAReason(
501496
WorkflowTaskFailedCause.WORKFLOW_TASK_FAILED_CAUSE_UNHANDLED_COMMAND,
502497
null,
@@ -680,12 +675,6 @@ private boolean unhandledMessages(RespondWorkflowTaskCompletedRequest request) {
680675
&& hasCompletionCommand(request.getCommandsList()));
681676
}
682677

683-
private boolean hasUnresolvedNexusCancelWithCompletion(
684-
RespondWorkflowTaskCompletedRequest request) {
685-
return !unresolvedNexusCancelRequests.isEmpty()
686-
&& hasCompletionCommand(request.getCommandsList());
687-
}
688-
689678
private boolean hasCompletionCommand(List<Command> commands) {
690679
for (Command command : commands) {
691680
if (WorkflowExecutionUtils.isWorkflowExecutionCompleteCommand(command)) {
@@ -916,7 +905,6 @@ private void processRequestCancelNexusOperation(
916905
historySize -> {
917906
nexusCancelRequestedEventIds.put(
918907
scheduleEventId, operation.getData().cancelRequestedEventId);
919-
unresolvedNexusCancelRequests.add(scheduleEventId);
920908
});
921909
ctx.addTimer(
922910
ProtobufTimeUtils.toJavaDuration(operation.getData().requestTimeout),
@@ -2435,8 +2423,6 @@ public void cancelNexusOperationRequestAcknowledge(NexusOperationRef ref) {
24352423
.setScheduledEventId(ref.getScheduledEventId())
24362424
.setRequestedEventId(cancelRequestedEventId))
24372425
.build());
2438-
ctx.onCommit(
2439-
historySize -> unresolvedNexusCancelRequests.remove(ref.getScheduledEventId()));
24402426
scheduleWorkflowTask(ctx);
24412427
ctx.unlockTimer("cancelNexusOperationRequestAcknowledge");
24422428
});
@@ -2459,8 +2445,6 @@ public void failNexusOperationCancelRequest(NexusOperationRef ref, Failure failu
24592445
.setRequestedEventId(cancelRequestedEventId)
24602446
.setFailure(failure))
24612447
.build());
2462-
ctx.onCommit(
2463-
historySize -> unresolvedNexusCancelRequests.remove(ref.getScheduledEventId()));
24642448
scheduleWorkflowTask(ctx);
24652449
ctx.unlockTimer("failNexusOperationCancelRequest");
24662450
});
@@ -2538,8 +2522,6 @@ private void timeoutNexusOperation(
25382522
}
25392523
operation.action(StateMachines.Action.TIME_OUT, ctx, timeoutType, 0);
25402524
nexusOperations.remove(scheduledEventId);
2541-
// The cancel response won't matter after a timeout, so clear the unresolved cancel.
2542-
unresolvedNexusCancelRequests.remove(scheduledEventId);
25432525
scheduleWorkflowTask(ctx);
25442526
});
25452527
} catch (StatusRuntimeException e) {
@@ -2580,8 +2562,6 @@ private void timeoutNexusRequest(long scheduledEventId, String requestMethod, in
25802562

25812563
if (isTerminalState(operation.getState())) {
25822564
nexusOperations.remove(scheduledEventId);
2583-
// Cancel response won't arrive after terminal state, unblock workflow completion.
2584-
unresolvedNexusCancelRequests.remove(scheduledEventId);
25852565
scheduleWorkflowTask(ctx);
25862566
} else {
25872567
retryNexusTask(ctx, operation);

0 commit comments

Comments
 (0)