61
}
62
}
63
>
workflowKey := definition.NewWorkflowKey(
api.go
64
>
request.NamespaceId,
65
>
request.Request.Execution.WorkflowId,
66
>
request.Request.Execution.RunId,
67
>
)
68
>
workflowLease, err := workflowConsistencyChecker.GetWorkflowLease(
69
>
ctx,
70
>
nil,
71
>
workflowKey,
72
>
locks.PriorityHigh,
73
>
)
74
>
if err != nil {
75
return nil, err
76
}
78
>
// Do not clear mutable state when query failed. Clear mutable state will fail other buffered pending queries.
79
>
// Note: QueryWorkflow should not alter mutable state, so it is safe to ignore error and not clear ms.
80
>
workflowLease.GetReleaseFn()(nil)
81
>
}()
82
83
// Context metadata is automatically set during mutable state transaction close for operations that mutate state.
84
// Since QueryWorkflow is readonly and never closes the transaction, we explicitly call SetContextMetadata
85
// here to ensure successful requests have workflow metadata populated in the context.
86
>
workflowLease.GetMutableState().SetContextMetadata(ctx)
api.go
87
>
88
>
req := request.GetRequest()
89
>
_, mutableStateStatus := workflowLease.GetMutableState().GetWorkflowStateStatus()
90
>
scope = scope.WithTags(metrics.StringTag("workflow_status", mutableStateStatus.String()))
91
>
if mutableStateStatus != enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING && req.QueryRejectCondition != enumspb.QUERY_REJECT_CONDITION_NONE {
92
notOpenReject := req.GetQueryRejectCondition() == enumspb.QUERY_REJECT_CONDITION_NOT_OPEN
93
notCompletedCleanlyReject := req.GetQueryRejectCondition() == enumspb.QUERY_REJECT_CONDITION_NOT_COMPLETED_CLEANLY && mutableStateStatus != enumspb.WORKFLOW_EXECUTION_STATUS_COMPLETED