workflow_task_completed_handler.go ×14

Frontier kind: Code frontier

unlabeled · c_e10ab179b6a6

4 tests · 9914 LOC · 267 files · introduces 0 tests · 89 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
17 ranges89 lines · 3 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2132 ranges9914 lines · 267 files · Browse complete extent
All tests (intent)
4 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

3 files ranked by introduced lines: 89 introduced LOC across 17 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/history/api/respondworkflowtaskcompleted/workflow_task_completed_handler.go 67 introduced LOC · 14 ranges

Open complete file

321 historyEvent, err = handler.handleCommandContinueAsNewWorkflow(ctx, command.GetContinueAsNewWorkflowExecutionCommandAttributes())
322
323 > case enumspb.COMMAND_TYPE_START_CHILD_WORKFLOW_EXECUTION: workflow_task_completed_handler.go
324 > historyEvent, err = handler.handleCommandStartChildWorkflow(ctx, command.GetStartChildWorkflowExecutionCommandAttributes())
325
326 case enumspb.COMMAND_TYPE_UPSERT_WORKFLOW_SEARCH_ATTRIBUTES:
1146 _ context.Context,
1147 attr *commandpb.StartChildWorkflowExecutionCommandAttributes,
1148 > ) (*historypb.HistoryEvent, error) { workflow_task_completed_handler.go
1149 > parentNamespaceEntry := handler.mutableState.GetNamespaceEntry()
1150 > parentNamespaceID := parentNamespaceEntry.ID()
1151 > parentNamespace := parentNamespaceEntry.Name()
1152 > targetNamespaceID := parentNamespaceID
1153 > targetNamespace := parentNamespace
1154 > if attr.GetNamespace() != "" {
1155 > targetNamespaceEntry, err := handler.namespaceRegistry.GetNamespace(namespace.Name(attr.GetNamespace()))
1156 > if err != nil {
1157 return nil, err
1158 }
1159 > targetNamespace = targetNamespaceEntry.Name() workflow_task_completed_handler.go
1160 > targetNamespaceID = targetNamespaceEntry.ID()
1161 } else {
1162 attr.Namespace = parentNamespace.String()
1163 }
1164
1165 > unaliasedSas, err := searchattribute.UnaliasFields( workflow_task_completed_handler.go
1166 > handler.searchAttributesMapperProvider,
1167 > attr.GetSearchAttributes(),
1168 > targetNamespace.String(),
1169 > )
1170 > if err != nil {
1171 return nil, handler.failWorkflowTaskOnInvalidArgument(enumspb.WORKFLOW_TASK_FAILED_CAUSE_BAD_SEARCH_ATTRIBUTES, err)
1172 }
1173 > if unaliasedSas != attr.GetSearchAttributes() { workflow_task_completed_handler.go
1174 // Create a copy of the `attr` to avoid modification of original `attr`,
1175 // which can be needed again in case of retry.
1179 }
1180
1181 > if err := handler.validateCommandAttr( workflow_task_completed_handler.go
1182 > func() (enumspb.WorkflowTaskFailedCause, error) {
1183 > return handler.attrValidator.ValidateStartChildExecutionAttributes(
1184 > parentNamespaceID,
1185 > targetNamespaceID,
1186 > targetNamespace,
1187 > attr,
1188 > handler.mutableState.GetExecutionInfo(),
1189 > handler.config.DefaultWorkflowTaskTimeout,
1190 > )
1191 > },
1192 ); err != nil || handler.stopProcessing {
1193 return nil, err
1195
1196 // Structural validation for VersioningOverride present on Start Child Workflow
1197 > if err := worker_versioning.ValidateVersioningOverrideStructure(attr.GetVersioningOverride()); err != nil { workflow_task_completed_handler.go
1198 return nil, handler.failWorkflowTask(enumspb.WORKFLOW_TASK_FAILED_CAUSE_BAD_START_CHILD_EXECUTION_ATTRIBUTES, err)
1199 }
1200
1201 > if handler.mutableState.GetAssignedBuildId() == "" { workflow_task_completed_handler.go
1202 > // TODO: this is supported in new versioning [cleanup-old-wv]
1203 > if attr.InheritBuildId && attr.TaskQueue.GetName() != "" && attr.TaskQueue.Name != handler.mutableState.GetExecutionInfo().TaskQueue {
1204 err := serviceerror.NewInvalidArgument("StartChildWorkflowExecution with UseCompatibleVersion cannot run on different task queue.")
1205 return nil, handler.failWorkflowTask(enumspb.WORKFLOW_TASK_FAILED_CAUSE_BAD_START_CHILD_EXECUTION_ATTRIBUTES, err)
1207 }
1208
1209 > metricsHandler := handler.metricsHandler.WithTags(metrics.HeaderCallsiteTag("StartChildWorkflowExecutionCommand")) workflow_task_completed_handler.go
1210 > metrics.HeaderSize.With(metricsHandler).Record(int64(attr.GetHeader().Size()))
1211 > if err := handler.sizeLimitChecker.checkIfPayloadSizeExceedsLimit(
1212 > metrics.CommandTypeTag(enumspb.COMMAND_TYPE_START_CHILD_WORKFLOW_EXECUTION.String()),
1213 > attr.GetInput().Size(),
1214 > "StartChildWorkflowExecutionCommandAttributes. Input exceeds size limit.",
1215 > ); err != nil {
1216 return nil, handler.terminateWorkflow(enumspb.WORKFLOW_TASK_FAILED_CAUSE_BAD_START_CHILD_EXECUTION_ATTRIBUTES, err)
1217 }
1218
1219 > if err := handler.sizeLimitChecker.checkIfMemoSizeExceedsLimit( workflow_task_completed_handler.go
1220 > attr.GetMemo(),
1221 > metrics.CommandTypeTag(enumspb.COMMAND_TYPE_START_CHILD_WORKFLOW_EXECUTION.String()),
1222 > "StartChildWorkflowExecutionCommandAttributes.Memo exceeds size limit.",
1223 > ); err != nil {
1224 return nil, handler.terminateWorkflow(enumspb.WORKFLOW_TASK_FAILED_CAUSE_BAD_START_CHILD_EXECUTION_ATTRIBUTES, err)
1225 }
1226
1227 // search attribute validation must be done after unaliasing keys
1228 > if err := handler.sizeLimitChecker.checkIfSearchAttributesSizeExceedsLimit( workflow_task_completed_handler.go
1229 > attr.GetSearchAttributes(),
1230 > targetNamespace,
1231 > metrics.CommandTypeTag(enumspb.COMMAND_TYPE_START_CHILD_WORKFLOW_EXECUTION.String()),
1232 > ); err != nil {
1233 return nil, handler.terminateWorkflow(enumspb.WORKFLOW_TASK_FAILED_CAUSE_BAD_START_CHILD_EXECUTION_ATTRIBUTES, err)
1234 }
1235
1236 // child workflow limit
1237 > if err := handler.sizeLimitChecker.checkIfNumChildWorkflowsExceedsLimit(); err != nil { workflow_task_completed_handler.go
1238 return nil, handler.failWorkflowTask(enumspb.WORKFLOW_TASK_FAILED_CAUSE_PENDING_CHILD_WORKFLOWS_LIMIT_EXCEEDED, err)
1239 }
1240
1241 > enabled := handler.config.EnableParentClosePolicy(parentNamespace.String()) workflow_task_completed_handler.go
1242 > if enabled {
1243 > enums.SetDefaultParentClosePolicy(&attr.ParentClosePolicy)
1244 > } else {
1245 attr.ParentClosePolicy = enumspb.PARENT_CLOSE_POLICY_ABANDON
1246 }
1247
1248 > enums.SetDefaultWorkflowIdReusePolicy(&attr.WorkflowIdReusePolicy) workflow_task_completed_handler.go
1249 >
1250 > event, _, err := handler.mutableState.AddStartChildWorkflowExecutionInitiatedEvent(
1251 > handler.workflowTaskCompletedID, attr, targetNamespaceID,
1252 > )
1253 > if err == nil {
1254 > // Keep track of all child initiated commands in this workflow task to validate request cancel commands
1255 > handler.initiatedChildExecutionsInBatch[attr.GetWorkflowId()] = struct{}{}
1256 > }
1257 > return event, err
1258 }
1259
go.temporal.io/server/service/history/api/respondworkflowtaskcompleted/workflow_size_checker.go 20 introduced LOC · 2 ranges

Open complete file

81 commandTypeTag metrics.Tag,
82 message string,
83 > ) error { workflow_size_checker.go
84 > metrics.MemoSize.With(c.metricsHandler).Record(
85 > int64(memo.Size()),
86 > commandTypeTag)
87 >
88 > executionInfo := c.mutableState.GetExecutionInfo()
89 > executionState := c.mutableState.GetExecutionState()
90 > err := common.CheckEventBlobSizeLimit(
91 > memo.Size(),
92 > c.memoSizeLimitWarn,
93 > c.memoSizeLimitError,
94 > executionInfo.NamespaceId,
95 > executionInfo.WorkflowId,
96 > executionState.RunId,
97 > c.metricsHandler.WithTags(commandTypeTag),
98 > c.logger,
99 > commandTypeTag.Value,
100 > )
101 > if err != nil {
102 return fmt.Errorf("%s", message) // nolint:err113
103 }
104 > return nil workflow_size_checker.go
105 }
106
go.temporal.io/server/common/enums/defaults.go 2 introduced LOC · 1 range

Open complete file

45 }
46
47 > func SetDefaultParentClosePolicy(f *enumspb.ParentClosePolicy) { defaults.go
48 > if *f == enumspb.PARENT_CLOSE_POLICY_UNSPECIFIED {
49 *f = enumspb.PARENT_CLOSE_POLICY_TERMINATE
50 }