Skip to content

Commit 15acf6d

Browse files
lina-temporalpdoerner
authored andcommitted
Check for an existing CHASM component before writing Workflow as component root (#8595)
# What changed? - Only add the Workflow root CHASM component if no root component already exists. - I think the overall feature should probably also be behind a feature flag. ## Why? - CHASM Scheduler functional tests are broken without this fix (scheduler mutable states 'become' chasmworkflows)
1 parent 945fc3c commit 15acf6d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

service/history/workflow/mutable_state_impl.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2586,8 +2586,15 @@ func (ms *MutableStateImpl) ApplyWorkflowExecutionStartedEvent(
25862586
// Initialize chasm tree once for new workflows.
25872587
// Using context.Background() because this is done outside an actual request context and the
25882588
// chasmworkflow.NewWorkflow does not actually use it currently.
2589-
mutableContext := chasm.NewMutableContext(context.Background(), ms.chasmTree.(*chasm.Node))
2590-
ms.chasmTree.(*chasm.Node).SetRootComponent(chasmworkflow.NewWorkflow(mutableContext, ms))
2589+
root, ok := ms.chasmTree.(*chasm.Node)
2590+
softassert.That(ms.logger, ok, "chasmTree cast failed")
2591+
2592+
validationContext := chasm.NewContext(context.Background(), root)
2593+
_, err := root.Component(validationContext, chasm.ComponentRef{})
2594+
if common.IsNotFoundError(err) {
2595+
mutableContext := chasm.NewMutableContext(context.Background(), root)
2596+
root.SetRootComponent(chasmworkflow.NewWorkflow(mutableContext, ms))
2597+
}
25912598
}
25922599

25932600
event := startEvent.GetWorkflowExecutionStartedEventAttributes()

0 commit comments

Comments
 (0)