workflow_state_replicator.go ×10

Frontier kind: Code frontier

unlabeled · c_6efddabade16

2 tests · 4659 LOC · 204 files · introduces 0 tests · 77 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
12 ranges77 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
731 ranges4659 lines · 204 files · Browse complete extent
All tests (intent)
2 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: 77 introduced LOC across 12 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/history/ndc/workflow_state_replicator.go 67 introduced LOC · 10 ranges

Open complete file

360 // local is stale, try to apply mutable state update
361 if snapshot != nil {
362 > return r.applySnapshot(ctx, namespaceID, wid, rid, archetypeID, wfCtx, releaseFn, ms, versionedTransitionArtifact, sourceClusterName) workflow_state_replicator.go
363 > }
364 return r.applyMutation(ctx, namespaceID, wid, rid, archetypeID, wfCtx, ms, releaseFn, versionedTransitionArtifact, sourceClusterName)
365 case errors.Is(err, consts.ErrStaleReference):
883 versionedTransition *replicationspb.VersionedTransitionArtifact,
884 sourceClusterName string,
886 > attribute := versionedTransition.GetSyncWorkflowStateSnapshotAttributes()
887 > if attribute == nil || attribute.State == nil {
888 var versionHistories *historyspb.VersionHistories
889 if localMutableState != nil {
900 )
901 }
902 > snapshot := attribute.State workflow_state_replicator.go
903 > if localMutableState == nil {
904 return r.applySnapshotWhenWorkflowNotExist(
905 ctx,
917 )
918 }
919 > return r.applySnapshotWhenWorkflowExist( workflow_state_replicator.go
920 > ctx,
921 > namespaceID,
922 > workflowID,
923 > runID,
924 > archetypeID,
925 > wfCtx,
926 > releaseFn,
927 > localMutableState,
928 > snapshot,
929 > versionedTransition.EventBatches,
930 > versionedTransition.NewRunInfo,
931 > sourceClusterName,
932 > )
933 }
934
946 newRunInfo *replicationspb.NewRunInfo,
947 sourceClusterName string,
948 > ) (retErr error) { workflow_state_replicator.go
949 > var isBranchSwitched bool
950 > var localTransitionHistory []*persistencespb.VersionedTransition
951 > var localVersionedTransition *persistencespb.VersionedTransition
952 > if len(localMutableState.GetExecutionInfo().TransitionHistory) != 0 {
953 > localTransitionHistory = transitionhistory.CopyVersionedTransitions(localMutableState.GetExecutionInfo().TransitionHistory)
954 > localVersionedTransition = transitionhistory.LastVersionedTransition(localTransitionHistory)
955 > sourceTransitionHistory := sourceMutableState.ExecutionInfo.TransitionHistory
956 > err := transitionhistory.StalenessCheck(sourceTransitionHistory, localVersionedTransition)
957 > switch {
958 case err == nil:
959 // no branch switch
988 }
989
990 > newBranchToken, err := r.bringLocalEventsUpToSourceCurrentBranch( workflow_state_replicator.go
991 > ctx,
992 > namespaceID,
993 > workflowID,
994 > runID,
995 > sourceClusterName,
996 > wfCtx,
997 > localMutableState,
998 > sourceMutableState.ExecutionInfo.VersionHistories,
999 > eventBlobs,
1000 > false,
1001 > )
1002 > defer func() {
1003 > r.deleteNewBranchWhenError(ctx, namespaceID, workflowID, runID, archetypeID, newBranchToken, retErr)
1004 > }()
1005 > if err != nil {
1006 return err
1007 }
1008
1009 > prevPendingChildIds := localMutableState.GetPendingChildIds() workflow_state_replicator.go
1010 >
1011 > err = localMutableState.ApplySnapshot(sourceMutableState)
1012 > if err != nil {
1013 return err
1014 }
1015
1016 > var newRunWorkflow Workflow workflow_state_replicator.go
1017 > if newRunInfo != nil {
1018 newRunWorkflow, err = r.getNewRunWorkflow(ctx, namespaceID, workflowID, archetypeID, localMutableState, newRunInfo)
1019 if err != nil {
1021 }
1022 }
1023 > targetWorkflow := NewWorkflow( workflow_state_replicator.go
1024 > r.clusterMetadata,
1025 > wfCtx,
1026 > localMutableState,
1027 > releaseFn,
1028 > )
1029 > if isBranchSwitched || len(localTransitionHistory) == 0 {
1030 // TODO: If branch switched, maybe refresh from LCA?
1031 err = r.taskRefresher.Refresh(ctx, localMutableState, false)
1042 }
1043
1044 > return r.transactionMgr.UpdateWorkflow( workflow_state_replicator.go
1045 > ctx,
1046 > isBranchSwitched,
1047 > archetypeID,
1048 > targetWorkflow,
1049 > newRunWorkflow,
1050 > )
1051 }
1052
go.temporal.io/server/service/history/interfaces/mutable_state_mock.go 10 introduced LOC · 2 ranges

Open complete file

1277
1278 // ApplySnapshot mocks base method.
1279 > func (m *MockMutableState) ApplySnapshot(snapshot *persistence.WorkflowMutableState) error { mutable_state_mock.go
1280 > m.ctrl.T.Helper()
1281 > ret := m.ctrl.Call(m, "ApplySnapshot", snapshot)
1282 > ret0, _ := ret[0].(error)
1283 > return ret0
1284 > }
1285
1286 // ApplySnapshot indicates an expected call of ApplySnapshot.
1287 > func (mr *MockMutableStateMockRecorder) ApplySnapshot(snapshot any) *gomock.Call { mutable_state_mock.go
1288 > mr.mock.ctrl.T.Helper()
1289 > return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ApplySnapshot", reflect.TypeOf((*MockMutableState)(nil).ApplySnapshot), snapshot)
1290 > }
1291
1292 // ApplyStartChildWorkflowExecutionFailedEvent mocks base method.