465
// Only valid if deployment is deleted or the request ID matches the current one.
466
if d.State.GetCreateRequestId() == args.GetRequestId() {
468
>
}
469
470
return temporal.NewNonRetryableApplicationError(errDeploymentAlreadyExists, errDeploymentAlreadyExists, nil)
471
}
472
473
>
func (d *WorkflowRunner) handleCreateWorkerDeployment(ctx workflow.Context, args *deploymentspb.CreateWorkerDeploymentArgs) (*deploymentspb.CreateWorkerDeploymentResponse, error) {
workflow.go
474
>
// use lock to enforce only one update at a time
475
>
err := d.lock.Lock(ctx)
476
>
if err != nil {
477
d.logger.Error("Could not acquire workflow lock")
478
return nil, serviceerror.NewDeadlineExceeded("Could not acquire workflow lock")
479
}
481
>
// Even if the update doesn't change the state we mark it as dirty because of created history events.
482
>
d.setStateChanged()
483
>
d.lock.Unlock()
484
>
}()
485
486
// Re-validate after acquiring lock
487
>
err = d.validateCreateWorkerDeployment(args)
workflow.go
488
>
if err != nil {
489
return nil, err
490
}
491
492
>
if d.State.GetCreateRequestId() == args.GetRequestId() {
workflow.go
493
>
// Duplicate request, return success without writing anything.
494
>
return &deploymentspb.CreateWorkerDeploymentResponse{
495
>
ConflictToken: d.State.ConflictToken,
496
>
}, nil
497
>
}
498
499
// At this point this a brand-new workflow.