diff --git a/service/frontend/api/handler.go b/service/frontend/api/handler.go index 95b1885f55c..629c1dbf1a0 100644 --- a/service/frontend/api/handler.go +++ b/service/frontend/api/handler.go @@ -1889,13 +1889,26 @@ func (wh *WorkflowHandler) StartWorkflowExecution( if err != nil { return nil, err } - wh.GetLogger().Debug("Start workflow execution request domainID", tag.WorkflowDomainID(domainID)) historyRequest, err := common.CreateHistoryStartWorkflowRequest( domainID, startRequest, time.Now(), wh.getPartitionConfig(ctx, domainName)) if err != nil { return nil, err } + // for debugging jitter workflow + // will be removed later + jitterStartSeconds := startRequest.GetJitterStartSeconds() + if startRequest.GetDomain() == "cadence-canary" && jitterStartSeconds > 0 { + wh.GetLogger().Debug("Start workflow execution request domainID", + tag.WorkflowDomainID(domainID), + tag.WorkflowID(startRequest.WorkflowID), + tag.Dynamic("JitterStartSeconds", jitterStartSeconds), + tag.Dynamic("firstDecisionTaskBackoffSeconds", historyRequest.GetFirstDecisionTaskBackoffSeconds()), + ) + } else { + wh.GetLogger().Debug("Start workflow execution request domainID", tag.WorkflowDomainID(domainID)) + } + resp, err = wh.GetHistoryClient().StartWorkflowExecution(ctx, historyRequest) if err != nil { return nil, err diff --git a/service/frontend/api/handler_test.go b/service/frontend/api/handler_test.go index 01cad1d331a..cb8affdf408 100644 --- a/service/frontend/api/handler_test.go +++ b/service/frontend/api/handler_test.go @@ -61,6 +61,7 @@ import ( const ( numHistoryShards = 10 testDomain = "test-domain" + canaryDomain = "cadence-canary" testDomainID = "e4f90ec0-1313-45be-9877-8aa41f72a45a" testWorkflowID = "test-workflow-id" testRunID = "2c8b555f-1f55-4955-9d1c-b980194555c9" @@ -596,6 +597,39 @@ func (s *workflowHandlerSuite) TestStartWorkflowExecution_IsolationGroupDrained( s.IsType(err, &types.BadRequestError{}) } +func (s *workflowHandlerSuite) TestStartWorkflowExecution_LogJitterTime() { + config := s.newConfig(dc.NewInMemoryClient()) + config.UserRPS = dc.GetIntPropertyFn(10) + wh := s.getWorkflowHandler(config) + jitterStart := int32(10) + + startWorkflowExecutionRequest := &types.StartWorkflowExecutionRequest{ + Domain: canaryDomain, + WorkflowID: "workflow-id", + WorkflowType: &types.WorkflowType{ + Name: "workflow-type", + }, + TaskList: &types.TaskList{ + Name: "task-list", + }, + JitterStartSeconds: &jitterStart, + ExecutionStartToCloseTimeoutSeconds: common.Int32Ptr(1), + TaskStartToCloseTimeoutSeconds: common.Int32Ptr(1), + RetryPolicy: &types.RetryPolicy{ + InitialIntervalInSeconds: 1, + BackoffCoefficient: 2, + MaximumIntervalInSeconds: 2, + MaximumAttempts: 1, + ExpirationIntervalInSeconds: 1, + }, + RequestID: uuid.New(), + } + s.mockDomainCache.EXPECT().GetDomainID(canaryDomain).Return(s.testDomainID, nil).Times(2) + s.mockHistoryClient.EXPECT().StartWorkflowExecution(gomock.Any(), gomock.Any()).Return(&types.StartWorkflowExecutionResponse{RunID: "test-rid"}, nil) + _, err := wh.StartWorkflowExecution(context.Background(), startWorkflowExecutionRequest) + s.NoError(err) +} + func (s *workflowHandlerSuite) TestDiagnoseWorkflowExecution_Success() { wh := s.getWorkflowHandler(s.newConfig(dc.NewInMemoryClient()))