Skip to content

Commit 88b3049

Browse files
authored
Set ParentClosePolicy default value (#481)
1 parent c16eef6 commit 88b3049

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

common/enums/defaults.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,9 @@ func SetDefaultTaskQueueKind(f *enumspb.TaskQueueKind) {
4545
*f = enumspb.TASK_QUEUE_KIND_NORMAL
4646
}
4747
}
48+
49+
func SetDefaultParentClosePolicy(f *enumspb.ParentClosePolicy) {
50+
if *f == enumspb.PARENT_CLOSE_POLICY_UNSPECIFIED {
51+
*f = enumspb.PARENT_CLOSE_POLICY_TERMINATE
52+
}
53+
}

service/history/decisionTaskHandler.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
"github.com/temporalio/temporal/common"
3939
"github.com/temporalio/temporal/common/backoff"
4040
"github.com/temporalio/temporal/common/cache"
41+
"github.com/temporalio/temporal/common/enums"
4142
"github.com/temporalio/temporal/common/log"
4243
"github.com/temporalio/temporal/common/log/tag"
4344
"github.com/temporalio/temporal/common/metrics"
@@ -761,10 +762,14 @@ func (handler *decisionTaskHandlerImpl) handleDecisionStartChildWorkflow(
761762
}
762763

763764
enabled := handler.config.EnableParentClosePolicy(handler.namespaceEntry.GetInfo().Name)
764-
if !enabled {
765+
if enabled {
766+
enums.SetDefaultParentClosePolicy(&attr.ParentClosePolicy)
767+
} else {
765768
attr.ParentClosePolicy = enumspb.PARENT_CLOSE_POLICY_ABANDON
766769
}
767770

771+
enums.SetDefaultWorkflowIdReusePolicy(&attr.WorkflowIdReusePolicy)
772+
768773
requestID := uuid.New()
769774
_, _, err = handler.mutableState.AddStartChildWorkflowExecutionInitiatedEvent(
770775
handler.decisionTaskCompletedID, requestID, attr,

service/history/historyEngine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2852,7 +2852,7 @@ func (e *historyEngineImpl) applyWorkflowIDReusePolicyHelper(
28522852
msg := "Workflow execution already finished. WorkflowId: %v, RunId: %v. Workflow Id reuse policy: reject duplicate workflow Id."
28532853
return getWorkflowAlreadyStartedError(msg, prevStartRequestID, execution.GetWorkflowId(), prevRunID)
28542854
default:
2855-
return serviceerror.NewInternal("Failed to process start workflow reuse policy.")
2855+
return serviceerror.NewInternal(fmt.Sprintf("Failed to process start workflow reuse policy: %v.", wfIDReusePolicy))
28562856
}
28572857

28582858
return nil

0 commit comments

Comments
 (0)