537
ctx context.Context,
538
request *persistence.CreateWorkflowExecutionRequest,
539
>
) (*persistence.CreateWorkflowExecutionResponse, error) {
context_impl.go
540
>
541
>
// do not try to get namespace cache within shard lock
542
>
namespaceID := namespace.ID(request.NewWorkflowSnapshot.ExecutionInfo.NamespaceId)
543
>
namespaceEntry, err := s.GetNamespaceRegistry().GetNamespaceByID(namespaceID)
544
>
if err != nil {
545
return nil, err
546
}
547
549
return nil, err
550
}
552
>
553
>
s.wLock()
554
>
555
>
// timeout check should be done within the shard lock, in case of shard lock contention
556
>
ctx, cancel, err := s.newDetachedContext(ctx)
557
>
if err != nil {
558
s.wUnlock()
559
return nil, err
560
}
562
>
563
>
if err := s.errorByState(); err != nil {
564
s.wUnlock()
565
return nil, err
566
}
567
568
>
if err := s.errorByNamespaceStateLocked(namespaceEntry.Name(), request.NewWorkflowSnapshot.ExecutionInfo.WorkflowId); err != nil {
context_impl.go
569
s.wUnlock()
570
return nil, err
571
}
572
573
>
requestCompletionFn, err := s.taskKeyManager.setAndTrackTaskKeys(
context_impl.go
574
>
request.NewWorkflowSnapshot.Tasks,
575
>
)
576
>
if err != nil {
577
s.wUnlock()
578
return nil, err
579
}
580
>
s.updateCloseTaskIDs(request.NewWorkflowSnapshot.ExecutionInfo, request.NewWorkflowSnapshot.Tasks)
context_impl.go
581
>
582
>
currentRangeID := s.getRangeIDLocked()
583
>
request.RangeID = currentRangeID
584
>
585
>
s.wUnlock()
586
>
resp, err := s.executionManager.CreateWorkflowExecution(ctx, request)
587
>
requestCompletionFn(err)
588
>
589
>
if err = s.handleWriteError(request.RangeID, err); err != nil {
590
return nil, err
591
}