diff --git a/common/primitives/uuid.go b/common/primitives/uuid.go index 733472e8ce..18e34a4499 100644 --- a/common/primitives/uuid.go +++ b/common/primitives/uuid.go @@ -29,7 +29,6 @@ import ( "encoding/hex" guuid "github.com/google/uuid" - "github.com/pborman/uuid" ) // UUID represents a 16-byte universally unique identifier @@ -93,7 +92,12 @@ func ValidateUUID(s string) (string, error) { // NewUUID generates a new random UUID func NewUUID() UUID { - return UUID(uuid.NewRandom()) + u, err := guuid.NewV7() + if err != nil { + // Should never happen, but this matches the behavior of pborman/uuid.NewRandom + return nil + } + return u[:] } // Downcast returns the UUID as a byte slice. This is necessary when passing to type sensitive interfaces such as cql. diff --git a/service/history/api/startworkflow/api.go b/service/history/api/startworkflow/api.go index 721e4637e4..94f9ae4722 100644 --- a/service/history/api/startworkflow/api.go +++ b/service/history/api/startworkflow/api.go @@ -29,7 +29,6 @@ import ( "errors" "time" - "github.com/google/uuid" commonpb "go.temporal.io/api/common/v1" enumspb "go.temporal.io/api/enums/v1" historypb "go.temporal.io/api/history/v1" @@ -44,6 +43,7 @@ import ( "go.temporal.io/server/common/namespace" "go.temporal.io/server/common/persistence" "go.temporal.io/server/common/persistence/visibility/manager" + "go.temporal.io/server/common/primitives" "go.temporal.io/server/common/tasktoken" "go.temporal.io/server/service/history/api" "go.temporal.io/server/service/history/consts" @@ -249,7 +249,7 @@ func (s *Starter) lockCurrentWorkflowExecution( // prepareNewWorkflow creates a new workflow context, and closes its mutable state transaction as snapshot. // It returns the creationContext which can later be used to insert into the executions table. func (s *Starter) prepareNewWorkflow(workflowID string) (*creationParams, error) { - runID := uuid.NewString() + runID := primitives.NewUUID().String() mutableState, err := api.NewWorkflowWithSignal( s.shardContext, s.namespace, @@ -403,7 +403,7 @@ func (s *Starter) resolveDuplicateWorkflowID( // Using a new RunID here to simplify locking: MultiOperation, that re-uses the Starter, is creating // a locked workflow context for each new workflow. Using a fresh RunID prevents a deadlock with the // previously created workflow context. - newRunID := uuid.NewString() + newRunID := primitives.NewUUID().String() currentExecutionUpdateAction, err := api.ResolveDuplicateWorkflowID( s.shardContext,