MCPcopy Create free account
hub / github.com/temporalio/temporal / lockAndCheckExecution

Function lockAndCheckExecution

common/persistence/sql/execution_util.go:629–665  ·  view source on GitHub ↗
(
	ctx context.Context,
	tx sqlplugin.Tx,
	shardID int32,
	namespaceID primitives.UUID,
	workflowID string,
	runID primitives.UUID,
	condition int64,
	dbRecordVersion int64,
)

Source from the content-addressed store, hash-verified

627}
628
629func lockAndCheckExecution(
630 ctx context.Context,
631 tx sqlplugin.Tx,
632 shardID int32,
633 namespaceID primitives.UUID,
634 workflowID string,
635 runID primitives.UUID,
636 condition int64,
637 dbRecordVersion int64,
638) error {
639
640 version, nextEventID, err := lockExecution(ctx, tx, shardID, namespaceID, workflowID, runID)
641 if err != nil {
642 return err
643 }
644
645 if dbRecordVersion == 0 {
646 if nextEventID != condition {
647 return &p.WorkflowConditionFailedError{
648 Msg: fmt.Sprintf("lockAndCheckExecution failed. Next_event_id was %v when it should have been %v.", nextEventID, condition),
649 NextEventID: nextEventID,
650 DBRecordVersion: version,
651 }
652 }
653 } else {
654 dbRecordVersion -= 1
655 if version != dbRecordVersion {
656 return &p.WorkflowConditionFailedError{
657 Msg: fmt.Sprintf("lockAndCheckExecution failed. DBRecordVersion expected: %v, actually %v.", dbRecordVersion, version),
658 NextEventID: nextEventID,
659 DBRecordVersion: version,
660 }
661 }
662 }
663
664 return nil
665}
666
667func lockExecution(
668 ctx context.Context,

Callers 2

Calls 1

lockExecutionFunction · 0.85

Tested by

no test coverage detected