diff --git a/go.mod b/go.mod index ad91580c8225..05a5066b2e0c 100644 --- a/go.mod +++ b/go.mod @@ -44,8 +44,8 @@ require ( go.opentelemetry.io/otel/metric v0.36.0 go.opentelemetry.io/otel/sdk v1.13.0 go.opentelemetry.io/otel/sdk/metric v0.36.0 - go.temporal.io/api v1.19.1-0.20230511202036-4dee2bb54577 - go.temporal.io/sdk v1.22.2 + go.temporal.io/api v1.19.1-0.20230515221100-0caa7c878f66 + go.temporal.io/sdk v1.22.1 go.temporal.io/version v0.3.0 go.uber.org/atomic v1.10.0 go.uber.org/automaxprocs v1.5.2 diff --git a/go.sum b/go.sum index aa589e6ed939..d00a99437494 100644 --- a/go.sum +++ b/go.sum @@ -1123,10 +1123,10 @@ go.opentelemetry.io/proto/otlp v0.15.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI go.opentelemetry.io/proto/otlp v0.19.0 h1:IVN6GR+mhC4s5yfcTbmzHYODqvWAp3ZedA2SJPI1Nnw= go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= go.temporal.io/api v1.19.1-0.20230322213042-07fb271d475b/go.mod h1:PLQJqp1YZZikmtGm9jIbzWpP3p6zS39WQjhsO/Hiw30= -go.temporal.io/api v1.19.1-0.20230511202036-4dee2bb54577 h1:BDU+5DlZuQicarZIXLhwXtup1dj8WUk+7XiK6m0brvA= -go.temporal.io/api v1.19.1-0.20230511202036-4dee2bb54577/go.mod h1:uITFvsxpTQT/ZRGMHTzmEXhdDkfA9o8Ik4cgw91TlM4= -go.temporal.io/sdk v1.22.2 h1:4bGxYekEN+FHAGXkRAxZcHs9k+fNO3RUmBRf97WH3So= -go.temporal.io/sdk v1.22.2/go.mod h1:LqYtPesETgMHktpH98Vk7WegNcikxErmmuaZPNWEnPw= +go.temporal.io/api v1.19.1-0.20230515221100-0caa7c878f66 h1:nLBDjkSXTJO/aoptKUSGmhVu78qiNIupn0j0RQGTs5M= +go.temporal.io/api v1.19.1-0.20230515221100-0caa7c878f66/go.mod h1:uITFvsxpTQT/ZRGMHTzmEXhdDkfA9o8Ik4cgw91TlM4= +go.temporal.io/sdk v1.22.1 h1:OawvkfZBy22H1W8A+9QQPhwlRLMFIGtmJQXpWaPHpeg= +go.temporal.io/sdk v1.22.1/go.mod h1:LqYtPesETgMHktpH98Vk7WegNcikxErmmuaZPNWEnPw= go.temporal.io/version v0.3.0 h1:dMrei9l9NyHt8nG6EB8vAwDLLTwx2SvRyucCSumAiig= go.temporal.io/version v0.3.0/go.mod h1:UA9S8/1LaKYae6TyD9NaPMJTZb911JcbqghI2CBSP78= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= diff --git a/service/history/workflow/cache/cache.go b/service/history/workflow/cache/cache.go index 068df4511c01..8f19598a92cc 100644 --- a/service/history/workflow/cache/cache.go +++ b/service/history/workflow/cache/cache.go @@ -28,13 +28,13 @@ package cache import ( "context" - "fmt" "sync/atomic" "time" "unicode/utf8" "github.com/pborman/uuid" commonpb "go.temporal.io/api/common/v1" + "go.temporal.io/api/enums/v1" "go.temporal.io/api/serviceerror" "go.temporal.io/server/common/cache" @@ -200,13 +200,13 @@ func (c *CacheImpl) getOrCreateWorkflowExecutionInternal( // Consider revisiting this if it causes too much GC activity releaseFunc := c.makeReleaseFunc(key, workflowCtx, forceClearContext, lockPriority) + const tailTime = 500 * time.Millisecond var timeout time.Time if deadline, ok := ctx.Deadline(); ok { - // TODO: what is our tail time? - timeout = deadline + timeout = deadline.Add(-tailTime) } - if headers.GetCallerInfo(ctx).CallerType == headers.CallerTypeBackground { + if headers.GetCallerInfo(ctx).CallerType != headers.CallerTypeAPI { timeout = time.Now().Add(500 * time.Millisecond) } ctxWithDeadline, cancel := context.WithDeadline(ctx, timeout) @@ -217,8 +217,7 @@ func (c *CacheImpl) getOrCreateWorkflowExecutionInternal( c.Release(key) handler.Counter(metrics.CacheFailures.GetMetricName()).Record(1) handler.Counter(metrics.AcquireLockFailedCounter.GetMetricName()).Record(1) - // TODO: what error return here? - return nil, nil, fmt.Errorf("Workflow is busy") + return nil, nil, serviceerror.NewResourceExhausted(enums.RESOURCE_EXHAUSTED_CAUSE_BUSY_WORKFLOW, "Workflow cannot be locked") } return workflowCtx, releaseFunc, nil }