Skip to content

Commit

Permalink
Remove lock on current workflow ID (#2872)
Browse files Browse the repository at this point in the history
* Remove lock on current workflow ID since this lock is close to noop
  NOTE: all writes to DB are serialized by the shard lock
  • Loading branch information
wxing1292 authored May 19, 2022
1 parent 65ea107 commit b618a94
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 61 deletions.
11 changes: 0 additions & 11 deletions service/history/historyEngine.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,17 +387,6 @@ func (e *historyEngineImpl) StartWorkflowExecution(

workflowID := request.GetWorkflowId()
runID := uuid.New()
// grab the current context as a Lock, nothing more
_, currentRelease, err := e.historyCache.GetOrCreateCurrentWorkflowExecution(
ctx,
namespaceID,
workflowID,
)
if err != nil {
return nil, err
}
defer func() { currentRelease(retError) }()

workflowContext, err := api.NewWorkflowWithSignal(
e.shard,
namespaceEntry,
Expand Down
34 changes: 0 additions & 34 deletions service/history/workflow/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ type (
ReleaseCacheFunc func(err error)

Cache interface {
GetOrCreateCurrentWorkflowExecution(
ctx context.Context,
namespaceID namespace.ID,
workflowID string,
) (Context, ReleaseCacheFunc, error)

GetOrCreateWorkflowExecution(
ctx context.Context,
namespaceID namespace.ID,
Expand Down Expand Up @@ -101,34 +95,6 @@ func NewCache(shard shard.Context) Cache {
}
}

func (c *CacheImpl) GetOrCreateCurrentWorkflowExecution(
ctx context.Context,
namespaceID namespace.ID,
workflowID string,
) (Context, ReleaseCacheFunc, error) {

scope := metrics.HistoryCacheGetOrCreateCurrentScope
c.metricsClient.IncCounter(scope, metrics.CacheRequests)
sw := c.metricsClient.StartTimer(scope, metrics.CacheLatency)
defer sw.Stop()

// using empty run ID as current workflow run ID
runID := ""
execution := commonpb.WorkflowExecution{
WorkflowId: workflowID,
RunId: runID,
}

return c.getOrCreateWorkflowExecutionInternal(
ctx,
namespaceID,
execution,
scope,
true,
CallerTypeAPI,
)
}

func (c *CacheImpl) GetOrCreateWorkflowExecution(
ctx context.Context,
namespaceID namespace.ID,
Expand Down
16 changes: 0 additions & 16 deletions service/history/workflow/cache_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b618a94

Please sign in to comment.