history_manager.go ×6

Frontier kind: Code frontier

unlabeled · c_14987d02ee29

63 tests · 3396 LOC · 157 files · introduces 0 tests · 60 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges60 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
546 ranges3396 lines · 157 files · Browse complete extent
All tests (intent)
63 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: 60 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/common/persistence/history_manager.go 54 introduced LOC · 6 ranges

Open complete file

51 }
52
53 > newAncestors := make([]*persistencespb.HistoryBranchRange, 0, len(forkBranch.Ancestors)+1) history_manager.go
54 >
55 > beginNodeID := GetBeginNodeID(forkBranch)
56 > if beginNodeID >= request.ForkNodeID {
57 // this is the case that new branch's ancestors doesn't include the forking branch
58 for _, br := range forkBranch.Ancestors {
68 }
69 }
70 > } else { history_manager.go
71 > // this is the case the new branch will inherit all ancestors from forking branch
72 > newAncestors = forkBranch.Ancestors
73 > newAncestors = append(newAncestors, &persistencespb.HistoryBranchRange{
74 > BranchId: forkBranch.GetBranchId(),
75 > BeginNodeId: beginNodeID,
76 > EndNodeId: request.ForkNodeID,
77 > })
78 > }
79 > newBranchInfo := &persistencespb.HistoryBranch{
80 > TreeId: forkBranch.TreeId,
81 > BranchId: uuid.NewString(),
82 > Ancestors: newAncestors,
83 > }
84 >
85 > // The above newBranchInfo is a lossy construction of the forked branch token from the original opaque branch token.
86 > // It only initializes with the fields it understands, which may inadvertently discard other misc fields. The
87 > // following is the replacement logic to correctly apply the updated fields into the original opaque branch token.
88 > newBranchToken, err := m.GetHistoryBranchUtil().UpdateHistoryBranchInfo(
89 > request.ForkBranchToken,
90 > newBranchInfo,
91 > request.NewRunID,
92 > )
93 > if err != nil {
94 return nil, err
95 }
96
97 > treeInfo := &persistencespb.HistoryTreeInfo{ history_manager.go
98 > BranchToken: newBranchToken,
99 > BranchInfo: newBranchInfo,
100 > ForkTime: timestamp.TimeNowPtrUtc(),
101 > Info: request.Info,
102 > }
103 >
104 > treeInfoBlob, err := m.serializer.HistoryTreeInfoToBlob(treeInfo)
105 > if err != nil {
106 return nil, err
107 }
108
109 > req := &InternalForkHistoryBranchRequest{ history_manager.go
110 > NewBranchToken: newBranchToken,
111 > ForkBranchInfo: forkBranch,
112 > TreeInfo: treeInfoBlob,
113 > ForkNodeID: request.ForkNodeID,
114 > NewBranchID: newBranchInfo.BranchId,
115 > Info: request.Info,
116 > ShardID: request.ShardID,
117 > }
118 >
119 > err = m.persistence.ForkHistoryBranch(ctx, req)
120 > if err != nil {
121 return nil, err
122 }
123
124 > return &ForkHistoryBranchResponse{ history_manager.go
125 > NewBranchToken: newBranchToken,
126 > }, nil
127 }
128
745 beginNodeID := common.FirstEventID
746 if len(branch.Ancestors) > 0 {
747 > beginNodeID = branch.Ancestors[len(branch.Ancestors)-1].GetEndNodeId() history_manager.go
748 > }
749 branchAncestors = append(branchAncestors, &persistencespb.HistoryBranchRange{
750 BranchId: branchID,
go.temporal.io/server/common/persistence/history_manager_util.go 6 introduced LOC · 2 ranges

Open complete file

120 return 1
121 }
122 > idx := len(bi.Ancestors) - 1 history_manager_util.go
123 > return bi.Ancestors[idx].GetEndNodeId()
124 }
125
126 func sortAncestors(ans []*persistencespb.HistoryBranchRange) {
127 if len(ans) > 0 {
128 > // sort ans based onf EndNodeID so that we can set BeginNodeID history_manager_util.go
129 > sort.Slice(ans, func(i, j int) bool { return (ans)[i].GetEndNodeId() < (ans)[j].GetEndNodeId() })
130 > (ans)[0].BeginNodeId = int64(1)
131 > for i := 1; i < len(ans); i++ {
132 (ans)[i].BeginNodeId = (ans)[i-1].GetEndNodeId()
133 }