Skip to content

Conversation

Quinn-With-Two-Ns
Copy link
Contributor

@Quinn-With-Two-Ns Quinn-With-Two-Ns commented Oct 19, 2025

Add support for FirstExecutionRunId to cancel and terminate to the Time skipping test server.


Note

Enable cancel and terminate operations to target a workflow chain via firstExecutionRunId, not just the current runId.

  • Server (test-server):
    • Add lookup/index by firstExecutionRunId using WorkflowChainId (namespace, workflowId, firstExecutionRunId).
    • On start, index executions in executionsByFirstExecutionRunId; expose getFirstExecutionRunId() on mutable state.
    • Update requestCancelWorkflowExecution and terminateWorkflowExecution to resolve executions via firstExecutionRunId when provided.
  • Tests:
    • Add FirstExecutionRunIdSupportTest covering cancel/terminate by firstExecutionRunId and after continue-as-new.

Written by Cursor Bugbot for commit 7856212. This will update automatically on new commits. Configure here.

@Quinn-With-Two-Ns Quinn-With-Two-Ns marked this pull request as ready for review October 20, 2025 14:39
@Quinn-With-Two-Ns Quinn-With-Two-Ns requested a review from a team as a code owner October 20, 2025 14:39
cursor[bot]

This comment was marked as outdated.

Comment on lines 282 to 299
if (workflowChainId != null) {
TestWorkflowMutableState mutableStateByFirstRunId = getMutableState(workflowChainId, false);
if (mutableStateByFirstRunId != null) {
return mutableStateByFirstRunId;
}
}

TestWorkflowMutableState mutableState = getMutableState(executionId, false);
if (mutableState != null) {
if (workflowChainId == null) {
return mutableState;
}
WorkflowExecution mutableStateExecution = mutableState.getExecutionId().getExecution();
if (mutableStateExecution.getRunId().equals(execution.getRunId())
&& firstExecutionRunId.equals(mutableState.getFirstExecutionRunId())) {
return mutableState;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Considering that workflow executions that have firstRunId are added to both maps in startWorkflowExecutionNoRunningCheckLocked, in what circumstances will the last if evaluate true (line 295)? If there is an execution with a matching first run ID, I'd expect it to have already returned inside the earlier if (line 285).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah good point, I think I overcomplicated the check. I simplified it a lot and should match how the current real server finds the correct mutable state. All the tests run on the real server and test server to validate this.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should add negative tests for what happens when the wrong first execution ID is provided to cancel/terminate request (both when there was and there wasn't continue-as-new).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

cursor[bot]

This comment was marked as outdated.

@Quinn-With-Two-Ns Quinn-With-Two-Ns force-pushed the test-server-first-exec-run-id branch from fceb387 to 7856212 Compare October 21, 2025 23:43
@Quinn-With-Two-Ns Quinn-With-Two-Ns merged commit b12ee45 into temporalio:master Oct 22, 2025
16 checks passed
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.

2 participants