mutable_state_impl.go ×29

Frontier kind: Code frontier

unlabeled · c_01280307db6d

336 tests · 3988 LOC · 165 files · introduces 0 tests · 103 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
30 ranges103 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
635 ranges3988 lines · 165 files · Browse complete extent
All tests (intent)
336 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.

2 files ranked by introduced lines: 103 introduced LOC across 30 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/history/workflow/mutable_state_impl.go 99 introduced LOC · 29 ranges

Open complete file

2969 requestID string,
2970 startEvent *historypb.HistoryEvent,
2971 > ) error { mutable_state_impl.go
2972 > if ms.executionInfo.NamespaceId != ms.namespaceEntry.ID().String() {
2973 return serviceerror.NewInternalf("applying conflicting namespace ID: %v != %v",
2974 ms.executionInfo.NamespaceId, ms.namespaceEntry.ID().String())
2975 }
2976 > if ms.executionInfo.WorkflowId != execution.GetWorkflowId() { mutable_state_impl.go
2977 return serviceerror.NewInternalf("applying conflicting workflow ID: %v != %v",
2978 ms.executionInfo.WorkflowId, execution.GetWorkflowId())
2979 }
2980 > if ms.executionState.RunId != execution.GetRunId() { mutable_state_impl.go
2981 return serviceerror.NewInternalf("applying conflicting run ID: %v != %v",
2982 ms.executionState.RunId, execution.GetRunId())
2983 }
2984
2985 > event := startEvent.GetWorkflowExecutionStartedEventAttributes() mutable_state_impl.go
2986 > ms.AttachRequestID(requestID, startEvent.EventType, startEvent.EventId)
2987 >
2988 > ms.approximateSize -= ms.executionInfo.Size()
2989 > ms.executionInfo.FirstExecutionRunId = event.GetFirstExecutionRunId()
2990 > ms.executionInfo.TaskQueue = event.TaskQueue.GetName()
2991 > ms.executionInfo.WorkflowTypeName = event.WorkflowType.GetName()
2992 > ms.executionInfo.WorkflowRunTimeout = event.GetWorkflowRunTimeout()
2993 > ms.executionInfo.WorkflowExecutionTimeout = event.GetWorkflowExecutionTimeout()
2994 > ms.executionInfo.DefaultWorkflowTaskTimeout = event.GetWorkflowTaskTimeout()
2995 > ms.executionInfo.OriginalExecutionRunId = event.GetOriginalExecutionRunId()
2996 >
2997 > ms.approximateSize -= ms.executionState.Size()
2998 > ms.executionState.FirstExecutionRunId = event.GetFirstExecutionRunId()
2999 > if err := ms.addCompletionCallbacks(
3000 > startEvent,
3001 > requestID,
3002 > event.GetCompletionCallbacks(),
3003 > ); err != nil {
3004 return err
3005 }
3006 > if _, err := ms.UpdateWorkflowStateStatus( mutable_state_impl.go
3007 > enumsspb.WORKFLOW_EXECUTION_STATE_CREATED,
3008 > enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
3009 > ); err != nil {
3010 return err
3011 }
3012 > ms.executionInfo.LastCompletedWorkflowTaskStartedEventId = common.EmptyEventID mutable_state_impl.go
3013 > ms.executionInfo.LastFirstEventId = startEvent.GetEventId()
3014 >
3015 > ms.executionInfo.WorkflowTaskVersion = common.EmptyVersion
3016 > ms.executionInfo.WorkflowTaskScheduledEventId = common.EmptyEventID
3017 > ms.executionInfo.WorkflowTaskStartedEventId = common.EmptyEventID
3018 > ms.executionInfo.WorkflowTaskRequestId = emptyUUID
3019 > ms.executionInfo.WorkflowTaskTimeout = timestamp.DurationFromSeconds(0)
3020 >
3021 > ms.executionInfo.CronSchedule = event.GetCronSchedule()
3022 >
3023 > if event.ParentWorkflowExecution != nil {
3024 ms.executionInfo.ParentNamespaceId = event.GetParentWorkflowNamespaceId()
3025 ms.executionInfo.ParentWorkflowId = event.ParentWorkflowExecution.GetWorkflowId()
3028 }
3029
3030 > if event.ParentInitiatedEventId != 0 { mutable_state_impl.go
3031 ms.executionInfo.ParentInitiatedId = event.GetParentInitiatedEventId()
3032 > } else { mutable_state_impl.go
3033 ms.executionInfo.ParentInitiatedId = common.EmptyEventID
3034 }
3035
3036 > if event.ParentInitiatedEventVersion != 0 { mutable_state_impl.go
3037 ms.executionInfo.ParentInitiatedVersion = event.GetParentInitiatedEventVersion()
3038 > } else { mutable_state_impl.go
3039 ms.executionInfo.ParentInitiatedVersion = common.EmptyVersion
3040 }
3041
3042 > if event.RootWorkflowExecution != nil { mutable_state_impl.go
3043 ms.executionInfo.RootWorkflowId = event.RootWorkflowExecution.GetWorkflowId()
3044 ms.executionInfo.RootRunId = event.RootWorkflowExecution.GetRunId()
3045 > } else { mutable_state_impl.go
3046 > ms.executionInfo.RootWorkflowId = execution.GetWorkflowId()
3047 > ms.executionInfo.RootRunId = execution.GetRunId()
3048 > }
3049
3050 // todo@time-skipping: apply time skipping to WorkflowStartDelay
3051 > ms.executionInfo.ExecutionTime = timestamppb.New( mutable_state_impl.go
3052 > ms.executionState.StartTime.AsTime().Add(event.GetFirstWorkflowTaskBackoff().AsDuration()),
3053 > )
3054 >
3055 > ms.executionInfo.Attempt = event.GetAttempt()
3056 > if !timestamp.TimeValue(event.GetWorkflowExecutionExpirationTime()).IsZero() {
3057 ms.executionInfo.WorkflowExecutionExpirationTime = event.GetWorkflowExecutionExpirationTime()
3058 }
3059
3060 > var workflowRunTimeoutTime time.Time mutable_state_impl.go
3061 > workflowRunTimeoutDuration := ms.executionInfo.WorkflowRunTimeout.AsDuration()
3062 > // if workflowRunTimeoutDuration == 0 then the workflowRunTimeoutTime will be 0
3063 > // meaning that there is not workflow run timeout
3064 > if workflowRunTimeoutDuration != 0 {
3065 firstWorkflowTaskDelayDuration := event.GetFirstWorkflowTaskBackoff().AsDuration()
3066 workflowRunTimeoutDuration = workflowRunTimeoutDuration + firstWorkflowTaskDelayDuration
3072 }
3073 }
3074 > ms.executionInfo.WorkflowRunExpirationTime = timestamppb.New(workflowRunTimeoutTime) mutable_state_impl.go
3075 >
3076 > if event.RetryPolicy != nil {
3077 ms.executionInfo.HasRetryPolicy = true
3078 ms.executionInfo.RetryBackoffCoefficient = event.RetryPolicy.GetBackoffCoefficient()
3083 }
3084
3085 > ms.executionInfo.AutoResetPoints = rolloverAutoResetPointsWithExpiringTime( mutable_state_impl.go
3086 > event.GetPrevAutoResetPoints(),
3087 > event.GetContinuedExecutionRunId(),
3088 > timestamp.TimeValue(startEvent.GetEventTime()),
3089 > ms.namespaceEntry.Retention(),
3090 > )
3091 >
3092 > if event.Memo != nil {
3093 ms.executionInfo.Memo = event.Memo.GetFields()
3094 }
3095 > if event.SearchAttributes != nil { mutable_state_impl.go
3096 ms.executionInfo.SearchAttributes = event.SearchAttributes.GetIndexedFields()
3097 }
3098
3099 > if event.GetVersioningOverride() != nil { mutable_state_impl.go
3100 if ms.executionInfo.VersioningInfo == nil {
3101 ms.executionInfo.VersioningInfo = &workflowpb.WorkflowExecutionVersioningInfo{}
3136 }
3137
3138 > if event.GetInheritedPinnedVersion() != nil { mutable_state_impl.go
3139 if ms.executionInfo.VersioningInfo == nil {
3140 ms.executionInfo.VersioningInfo = &workflowpb.WorkflowExecutionVersioningInfo{}
3147 // target version upgrade from the started event. This is the same public API
3148 // type, so no conversion needed.
3149 > if event.GetContinuedExecutionRunId() != "" && event.GetInheritedPinnedVersion() != nil { mutable_state_impl.go
3150 ms.executionInfo.DeclinedTargetVersionUpgrade = event.GetDeclinedTargetVersionUpgrade()
3151 }
3152
3153 // Populate the versioningInfo if the inheritedAutoUpgradeInfo is present.
3154 > if event.GetInheritedAutoUpgradeInfo() != nil { mutable_state_impl.go
3155 ms.SetVersioningRevisionNumber(event.GetInheritedAutoUpgradeInfo().GetSourceDeploymentRevisionNumber())
3156 // TODO (Shivam): Remove this once you make SetDeploymentVersion and SetVersioningBehavior methods with nil checks
3164 }
3165
3166 > if inheritedBuildId := event.InheritedBuildId; inheritedBuildId != "" { mutable_state_impl.go
3167 ms.executionInfo.InheritedBuildId = inheritedBuildId
3168 if err := ms.UpdateBuildIdAssignment(inheritedBuildId); err != nil {
3169 return err
3170 }
3171 > } else if event.SourceVersionStamp.GetUseVersioning() && event.SourceVersionStamp.GetBuildId() != "" || mutable_state_impl.go
3172 > ms.GetEffectiveVersioningBehavior() != enumspb.VERSIONING_BEHAVIOR_UNSPECIFIED {
3173 // TODO: [cleanup-old-wv]
3174 limit := ms.config.SearchAttributesSizeOfValueLimit(string(ms.namespaceEntry.Name()))
3181
3182 // This will include override and inheritance, but not transition, because WF never starts with a transition
3183 > ms.executionInfo.WorkerDeploymentName = ms.GetEffectiveDeployment().GetSeriesName() mutable_state_impl.go
3184 >
3185 > if inheritedBuildId := event.InheritedBuildId; inheritedBuildId != "" {
3186 ms.executionInfo.InheritedBuildId = inheritedBuildId
3187 if err := ms.UpdateBuildIdAssignment(inheritedBuildId); err != nil {
3190 }
3191
3192 > ms.executionInfo.MostRecentWorkerVersionStamp = event.SourceVersionStamp mutable_state_impl.go
3193 > ms.executionInfo.Priority = event.Priority
3194 >
3195 > if tsc, stateProp := event.GetTimeSkippingConfig(), event.GetTimeSkippingStatePropagation(); tsc != nil || stateProp.GetInitialSkippedDuration().AsDuration() > 0 {
3196 if err := ms.initTimeSkippingInfo(tsc, stateProp); err != nil {
3197 return err
3199 }
3200
3201 > ms.approximateSize += ms.executionInfo.Size() mutable_state_impl.go
3202 > ms.approximateSize += ms.executionState.Size()
3203 >
3204 > ms.writeEventToCache(startEvent)
3205 > return nil
3206 }
3207
3386 requestID string,
3387 completionCallbacks []*commonpb.Callback,
3388 > ) error { mutable_state_impl.go
3389 > if len(completionCallbacks) == 0 {
3390 return nil
3391 }
6305 newExecutionStartTime time.Time,
6306 namespaceRetention time.Duration,
6307 > ) *workflowpb.ResetPoints { mutable_state_impl.go
6308 > if resetPoints.GetPoints() == nil {
6309 > return resetPoints
6310 > }
6311 newPoints := make([]*workflowpb.ResetPointInfo, 0, len(resetPoints.Points))
6312 // For continue-as-new, new execution start time is the same as previous execution close time,
9603 //
9604 // Note: Deployment objects are immutable, never change their fields.
9605 > func (ms *MutableStateImpl) GetEffectiveDeployment() *deploymentpb.Deployment { mutable_state_impl.go
9606 > return GetEffectiveDeployment(ms.GetExecutionInfo().GetVersioningInfo())
9607 > }
9608
9609 func (ms *MutableStateImpl) GetWorkerDeploymentSA() string {
go.temporal.io/server/service/history/workflow/util.go 4 introduced LOC · 1 range

Open complete file

178 //
179 //nolint:revive // cognitive complexity to reduce after old code clean up
180 > func GetEffectiveDeployment(versioningInfo *workflowpb.WorkflowExecutionVersioningInfo) *deploymentpb.Deployment { util.go
181 > if versioningInfo == nil {
182 > return nil
183 > } else if transition := versioningInfo.GetVersionTransition(); transition != nil {
184 if v := transition.GetDeploymentVersion(); v != nil { // v0.32
185 return worker_versioning.DeploymentFromExternalDeploymentVersion(v)