Add check that context is valid after trying to dispatch query on sticky
@@ -741,7 +741,6 @@ func (e *historyEngineImpl) QueryWorkflow(
ctx ctx.Context,
request *h.QueryWorkflowRequest,
) (retResp *h.QueryWorkflowResponse, retErr error) {
-
context, release, err := e.historyCache.getOrCreateWorkflowExecution(ctx, request.GetDomainUUID(), *request.GetRequest().GetExecution())
if err != nil {
return nil, err
@@ -864,11 +863,12 @@ func (e *historyEngineImpl) queryDirectlyThroughMatching(
return &h.QueryWorkflowResponse{Response: matchingResp}, nil
}
if yarpcError, ok := err.(*yarpcerrors.Status); !ok || yarpcError.Code() != yarpcerrors.CodeDeadlineExceeded {
- e.logger.Info("Query directly though matching failed",
+ e.logger.Error("Query directly though matching on sticky failed",
tag.WorkflowDomainName(queryRequest.GetDomain()),
tag.WorkflowID(queryRequest.Execution.GetWorkflowId()),
tag.WorkflowRunID(queryRequest.Execution.GetRunId()),
- tag.WorkflowQueryType(queryRequest.Query.GetQueryType()))
+ tag.WorkflowQueryType(queryRequest.Query.GetQueryType()),
+ tag.Error(err))
return nil, err
}
// this means sticky timeout, should try using the normal tasklist
@@ -880,6 +880,7 @@ func (e *historyEngineImpl) queryDirectlyThroughMatching(
tag.WorkflowQueryType(queryRequest.Query.GetQueryType()),
tag.WorkflowTaskListName(msResp.GetStickyTaskList().GetName()),
tag.WorkflowNextEventID(msResp.GetNextEventId()))
+
resetContext, cancel := context.WithTimeout(context.Background(), 5*time.Second)
_, err = e.ResetStickyTaskList(resetContext, &h.ResetStickyTaskListRequest{
DomainUUID: common.StringPtr(domainID),
@@ -892,13 +893,23 @@ func (e *historyEngineImpl) queryDirectlyThroughMatching(
}
matchingRequest.TaskList = msResp.TaskList
+ if err := common.IsValidContext(ctx); err != nil {
+ e.logger.Error("Context expired before query could be attempted on nonSticky",
+ tag.WorkflowDomainName(queryRequest.GetDomain()),
+ tag.WorkflowID(queryRequest.Execution.GetWorkflowId()),
+ tag.WorkflowRunID(queryRequest.Execution.GetRunId()),
+ tag.WorkflowQueryType(queryRequest.Query.GetQueryType()),
+ tag.Error(err))
+ return nil, err
+ }
matchingResp, err := e.matchingClient.QueryWorkflow(ctx, matchingRequest)
if err != nil {
- e.logger.Info("Query directly though matching failed",
+ e.logger.Error("Query directly though matching on non-sticky failed",
tag.WorkflowDomainName(queryRequest.GetDomain()),
tag.WorkflowID(queryRequest.Execution.GetWorkflowId()),
tag.WorkflowRunID(queryRequest.Execution.GetRunId()),
- tag.WorkflowQueryType(queryRequest.Query.GetQueryType()))
+ tag.WorkflowQueryType(queryRequest.Query.GetQueryType()),
+ tag.Error(err))
return nil, err
}
return &h.QueryWorkflowResponse{Response: matchingResp}, nil
