workflow_state_replicator.go ×8

Frontier kind: Code frontier

unlabeled · c_248ad87937a5

5 tests · 4265 LOC · 197 files · introduces 0 tests · 35 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges35 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
623 ranges4265 lines · 197 files · Browse complete extent
All tests (intent)
5 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.

1 file ranked by introduced lines: 35 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/history/ndc/workflow_state_replicator.go 35 introduced LOC · 8 ranges

Open complete file

227 versionedTransitionArtifact *replicationspb.VersionedTransitionArtifact,
228 sourceClusterName string,
229 > ) (retError error) { workflow_state_replicator.go
230 > if versionedTransitionArtifact.StateAttributes == nil {
231 return serviceerror.NewInvalidArgument("both snapshot and mutation are nil")
232 }
233
234 > _, snapshot, executionState, executionInfo, err := parseVersionedTransitionAttributes(versionedTransitionArtifact) workflow_state_replicator.go
235 > if err != nil {
236 return err
237 }
238
239 > namespaceID := namespace.ID(executionInfo.GetNamespaceId()) workflow_state_replicator.go
240 > wid := executionInfo.GetWorkflowId()
241 > rid := executionState.GetRunId()
242 >
243 > // emitApplied gates the best-effort "applied" lifecycle event; computed once here so the gate
244 > // lives at the call site, like the other replication lifecycle emitters.
245 > emitApplied := r.eventLogger != nil && r.shardContext.GetConfig().EmitReplicationLifecycleEvents()
246 > // ms is the mutable state being applied; appliedMS is a snapshot of its post-apply state taken
247 > // under the workflow lock (see the releaseFn wrapper below) for the deferred emit. Reading the
248 > // live ms after the lock is released would race with the next writer.
249 > var ms historyi.MutableState
250 > var appliedMS *persistencespb.WorkflowMutableState
251 > defer func() {
252 > if emitApplied && retError == nil {
253 r.emitReplicationVersionedTransitionApplied(namespaceID, wid, rid, appliedMS)
254 }
255 }()
256
257 > wfCtx, releaseFn, err := r.workflowCache.GetOrCreateChasmExecution( workflow_state_replicator.go
258 > ctx,
259 > r.shardContext,
260 > namespaceID,
261 > &commonpb.WorkflowExecution{
262 > WorkflowId: wid,
263 > RunId: rid,
264 > },
265 > archetypeID,
266 > locks.PriorityHigh,
267 > )
268 > if err != nil {
269 return err
270 }
271 > if emitApplied { workflow_state_replicator.go
272 // Snapshot the post-apply mutable state at release time: the only point that is both after
273 // the apply (which mutates ms in place) and still under the workflow lock, since the apply
281 }
282 }
283 > defer func() { workflow_state_replicator.go
284 > if rec := recover(); rec != nil {
285 releaseFn(errPanic)
286 panic(rec)
287 }
288 > releaseFn(retError) workflow_state_replicator.go
289 }()
290 > if versionedTransitionArtifact.IsFirstSync { workflow_state_replicator.go
291 // this is the first replication task for this workflow
292 // TODO: Handle reset case to reduce the amount of history events write