379
currentExecutionMissing := currentWorkflow == nil
380
if currentExecutionMissing {
381
>
// There is no current_executions row (the current run was deleted), so the base->reset link
workflow_resetter.go
382
>
// and the new current run cannot be committed atomically: re-establishing a missing current
383
>
// requires a brand-new insert, while the base run needs a bypass-current update, and no
384
>
// single Transaction method does both. Write base-first so retries are safe: if the create
385
>
// fails, a retry rewrites the base link and the brand-new insert still succeeds. Creating
386
>
// first would leave the reset run as current and permanently conflict with the create.
387
>
baseWorkflowMutation, baseWorkflowEventsSeq, err := baseWorkflow.GetMutableState().CloseTransactionAsMutation(
388
>
ctx,
389
>
historyi.TransactionPolicyActive,
390
>
)
391
>
if err != nil {
392
return err
393
}
395
>
ctx,
396
>
persistence.UpdateWorkflowModeBypassCurrent,
397
>
chasm.WorkflowArchetypeID,
398
>
baseWorkflow.GetMutableState().GetCurrentVersion(),
399
>
baseWorkflowMutation,
400
>
baseWorkflowEventsSeq,
401
>
nil,
402
>
nil,
403
>
nil,
404
>
baseWorkflow.GetMutableState().IsWorkflow(),
405
>
); err != nil {
406
return err
407
}
409
>
ctx,
410
>
persistence.CreateWorkflowModeBrandNew,
411
>
chasm.WorkflowArchetypeID,
412
>
resetWorkflow.GetMutableState().GetCurrentVersion(),
413
>
resetWorkflowSnapshot,
414
>
resetWorkflowEventsSeq,
415
>
resetWorkflow.GetMutableState().IsWorkflow(),
416
>
); err != nil {
417
return err
418
}
420
}
421