116
ctx context.Context,
117
branchIndex int32,
119
>
120
>
versionHistories := r.mutableState.GetExecutionInfo().GetVersionHistories()
121
>
replayVersionHistory, err := versionhistory.GetVersionHistory(versionHistories, branchIndex)
122
>
if err != nil {
123
return nil, err
124
}
125
>
lastItem, err := versionhistory.GetLastVersionHistoryItem(replayVersionHistory)
conflict_resolver.go
126
>
if err != nil {
127
return nil, err
128
}
129
131
>
executionState := r.mutableState.GetExecutionState()
132
>
workflowKey := definition.NewWorkflowKey(
133
>
executionInfo.NamespaceId,
134
>
executionInfo.WorkflowId,
135
>
executionState.RunId,
136
>
)
137
>
historySize := r.mutableState.GetHistorySize()
138
>
externalPayloadSize := r.mutableState.GetExternalPayloadSize()
139
>
externalPayloadCount := r.mutableState.GetExternalPayloadCount()
140
>
141
>
rebuildMutableState, _, err := r.stateRebuilder.Rebuild(
142
>
ctx,
143
>
timestamp.TimeValue(executionState.StartTime),
144
>
workflowKey,
145
>
replayVersionHistory.GetBranchToken(),
146
>
lastItem.GetEventId(),
147
>
new(lastItem.GetVersion()),
148
>
workflowKey,
149
>
replayVersionHistory.GetBranchToken(),
150
>
findStartRequestID(executionState),
151
>
)
152
>
if err != nil {
153
return nil, err
154
}
155
156
// after rebuilt verification
157
>
rebuildVersionHistories := rebuildMutableState.GetExecutionInfo().GetVersionHistories()
conflict_resolver.go
158
>
rebuildVersionHistory, err := versionhistory.GetCurrentVersionHistory(rebuildVersionHistories)
159
>
rebuildMutableState.GetExecutionInfo().PreviousTransitionHistory = r.mutableState.GetExecutionInfo().PreviousTransitionHistory
160
>
rebuildMutableState.GetExecutionInfo().LastTransitionHistoryBreakPoint = r.mutableState.GetExecutionInfo().LastTransitionHistoryBreakPoint
161
>
if err != nil {
162
return nil, err
163
}
164
166
return nil, serviceerror.NewInternal("ConflictResolver encounter mismatch version history after Rebuild")
167
}
168
169
// set the current branch index to target branch index
170
>
if err := versionhistory.SetCurrentVersionHistoryIndex(versionHistories, branchIndex); err != nil {
conflict_resolver.go
171
return nil, err
172
}
173
>
rebuildMutableState.GetExecutionInfo().VersionHistories = versionHistories
conflict_resolver.go
174
>
rebuildMutableState.AddHistorySize(historySize)
175
>
rebuildMutableState.AddExternalPayloadSize(externalPayloadSize)
176
>
rebuildMutableState.AddExternalPayloadCount(externalPayloadCount)
177
>
// set the update condition from original mutable state
178
>
rebuildMutableState.SetUpdateCondition(r.mutableState.GetUpdateCondition())
179
>
180
>
r.context.Clear()
181
>
return rebuildMutableState, nil
182
}