state_rebuilder.go ×6

Frontier kind: Joint frontier

unlabeled · c_f51bd4776f36

1 test · 6458 LOC · 218 files · introduces 1 test · 49 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
7 ranges49 lines · 2 files
Tests
1 test

Contains — complete concept membership

All code (extent)
1258 ranges6458 lines · 218 files · Browse complete extent
All tests (intent)
1 testBrowse 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.

1 test introduced at this concept.

Introduced code

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

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

go.temporal.io/server/service/history/ndc/state_rebuilder.go 47 introduced LOC · 6 ranges

Open complete file

160 targetBranchToken []byte,
161 currentMutableState *persistencespb.WorkflowMutableState,
162 > ) (historyi.MutableState, RebuildStats, error) { state_rebuilder.go
163 > // Use the original start request ID handlers can still correlate rebuilt callbacks to the correct BufferedStart entry.
164 > rebuiltMutableState, lastTxnId, err := r.buildMutableStateFromEvent(
165 > ctx,
166 > now,
167 > baseWorkflowIdentifier,
168 > baseBranchToken,
169 > baseLastEventID,
170 > baseLastEventVersion,
171 > targetWorkflowIdentifier,
172 > targetBranchToken,
173 > findStartRequestID(currentMutableState.GetExecutionState()),
174 > )
175 > if err != nil {
176 return nil, RebuildStats{}, err
177 }
178 > copyToRebuildMutableState(rebuiltMutableState, currentMutableState) state_rebuilder.go
179 > versionHistories := rebuiltMutableState.GetExecutionInfo().GetVersionHistories()
180 > currentVersionHistory, err := versionhistory.GetCurrentVersionHistory(versionHistories)
181 > if err != nil {
182 return nil, RebuildStats{}, err
183 }
184 > items := versionhistory.CopyVersionHistoryItems(currentVersionHistory.Items) state_rebuilder.go
185 >
186 > // This is a workaround to bypass the version history update check:
187 > // We need to use Active policy to close the transaction. We need to clear the version history items here to
188 > // let it pass the version history update logic and then re-assign the version history items after transaction.
189 > currentVersionHistory.Items = nil
190 >
191 > // close rebuilt mutable state transaction clearing all generated tasks, etc.
192 > _, _, err = rebuiltMutableState.CloseTransactionAsSnapshot(ctx, historyi.TransactionPolicyActive)
193 > if err != nil {
194 return nil, RebuildStats{}, err
195 }
196 > currentVersionHistory.Items = items state_rebuilder.go
197 >
198 > rebuiltMutableState.GetExecutionInfo().LastFirstEventTxnId = lastTxnId
199 >
200 > // refresh tasks to be generated
201 > // TODO: ideally the executionTimeoutTimerTaskStatus field should be carried over
202 > // from the base run. However, RefreshTasks always resets that field and
203 > // force regenerates the execution timeout timer task.
204 > if err := r.taskRefresher.Refresh(ctx, rebuiltMutableState, false); err != nil {
205 return nil, RebuildStats{}, err
206 }
207
208 > return rebuiltMutableState, RebuildStats{ state_rebuilder.go
209 > HistorySize: r.rebuiltHistorySize,
210 > ExternalPayloadSize: r.rebuiltExternalPayloadSize,
211 > ExternalPayloadCount: r.rebuiltExternalPayloadCount,
212 > }, nil
213 }
214
216 rebuiltMutableState historyi.MutableState,
217 currentMutableState *persistencespb.WorkflowMutableState,
218 > ) { state_rebuilder.go
219 > rebuiltMutableState.GetExecutionInfo().TransitionHistory = transitionhistory.CopyVersionedTransitions(currentMutableState.GetExecutionInfo().TransitionHistory)
220 > rebuiltMutableState.GetExecutionInfo().PreviousTransitionHistory = transitionhistory.CopyVersionedTransitions(currentMutableState.GetExecutionInfo().PreviousTransitionHistory)
221 > rebuiltMutableState.GetExecutionInfo().LastTransitionHistoryBreakPoint = transitionhistory.CopyVersionedTransition(currentMutableState.GetExecutionInfo().LastTransitionHistoryBreakPoint)
222 > }
223
224 func (r *StateRebuilderImpl) buildMutableStateFromEvent(
go.temporal.io/server/common/persistence/transitionhistory/transition_history.go 2 introduced LOC · 1 range

Open complete file

27 ) *persistencespb.VersionedTransition {
28 if transition == nil {
29 > return nil transition_history.go
30 > }
31 return common.CloneProto(transition)
32 }