history_manager.go ×7

Frontier kind: Code frontier

unlabeled · c_342e53db1beb

91 tests · 3397 LOC · 158 files · introduces 0 tests · 70 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges70 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
542 ranges3397 lines · 158 files · Browse complete extent
All tests (intent)
91 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: 70 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 60 introduced LOC · 7 ranges

Open complete file

214 ctx context.Context,
215 request *TrimHistoryBranchRequest,
216 > ) (*TrimHistoryBranchResponse, error) { history_manager.go
217 >
218 > shardID := request.ShardID
219 > minNodeID := common.FirstEventID
220 > maxNodeID := request.NodeID + 1
221 > pageSize := trimHistoryBranchPageSize
222 >
223 > branch, err := m.GetHistoryBranchUtil().ParseHistoryBranchInfo(request.BranchToken)
224 > if err != nil {
225 return nil, fmt.Errorf("unable to parse history branch info: %w", err)
226 }
227 > treeID := branch.TreeId history_manager.go
228 > branchID := branch.BranchId
229 > branchAncestors := branch.Ancestors
230 >
231 > // merge tree ID & branch ID into branch ancestors so the processing logic is simple
232 > beginNodeID := common.FirstEventID
233 > if len(branch.Ancestors) > 0 {
234 beginNodeID = branch.Ancestors[len(branch.Ancestors)-1].GetEndNodeId()
235 }
236 > branchAncestors = append(branchAncestors, &persistencespb.HistoryBranchRange{ history_manager.go
237 > BranchId: branchID,
238 > BeginNodeId: beginNodeID,
239 > EndNodeId: maxNodeID,
240 > })
241 >
242 > var pageToken []byte
243 > transactionIDToNode := map[int64]historyNodeMetadata{}
244 > for doContinue := true; doContinue; doContinue = len(pageToken) > 0 {
245 > token, err := m.deserializeToken(pageToken, minNodeID-1, defaultLastTransactionID)
246 > if err != nil {
247 return nil, fmt.Errorf("unable to deserialize token: %w", err)
248 }
249
250 > nodes, token, err := m.readRawHistoryBranch( history_manager.go
251 > ctx,
252 > request.BranchToken,
253 > shardID,
254 > branchAncestors,
255 > minNodeID,
256 > maxNodeID,
257 > token,
258 > pageSize,
259 > true,
260 > )
261 > if err != nil {
262 return nil, fmt.Errorf("unable to read raw history branch: %w", err)
263 }
264
265 > branchID := branchAncestors[token.CurrentRangeIndex].BranchId history_manager.go
266 > for _, node := range nodes {
267 > transactionIDToNode[node.TransactionID] = historyNodeMetadata{
268 > branchInfo: &persistencespb.HistoryBranch{
269 > TreeId: treeID,
270 > BranchId: branchID,
271 > Ancestors: branchAncestors[0:token.CurrentRangeIndex],
272 > },
273 > nodeID: node.NodeID,
274 > transactionID: node.TransactionID,
275 > prevTransactionID: node.PrevTransactionID,
276 > }
277 > }
278
279 > pageToken, err = m.serializeToken(token, false) history_manager.go
280 > if err != nil {
281 return nil, fmt.Errorf("unable to serialize token: %w", err)
282 }
283 }
284
285 > nodesToTrim, err := validateNodeChainAndTrim( history_manager.go
286 > request.NodeID,
287 > request.TransactionID,
288 > transactionIDToNode,
289 > )
290 > if err != nil {
291 m.logger.Debug("unable to trim history branch due to existing history node not fully onboarded", tag.Error(err))
292 return &TrimHistoryBranchResponse{}, nil
go.temporal.io/server/common/persistence/history_node_util.go 10 introduced LOC · 1 range

Open complete file

24 tailTransactionID int64,
25 transactionIDToNode map[int64]historyNodeMetadata,
26 > ) ([]historyNodeMetadata, error) { history_node_util.go
27 >
28 > nodeIDToNodes := indexNodeIDToNode(transactionIDToNode)
29 >
30 > nodeChain, err := reverselyLinkNode(
31 > tailNodeID,
32 > tailTransactionID,
33 > transactionIDToNode,
34 > )
35 > if err != nil {
36 return nil, err
37 }