Skip to content

Commit 0f9a838

Browse files
committed
[Pause] Reject queries when workflow is paused
1 parent 3ee83f7 commit 0f9a838

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

service/history/api/queryworkflow/api.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ func Invoke(
9696
}, nil
9797
}
9898
}
99+
// If workflow is paused, return query rejected with PAUSED status.
100+
if mutableStateStatus == enumspb.WORKFLOW_EXECUTION_STATUS_PAUSED {
101+
return &historyservice.QueryWorkflowResponse{
102+
Response: &workflowservice.QueryWorkflowResponse{
103+
QueryRejected: &querypb.QueryRejected{
104+
Status: enumspb.WORKFLOW_EXECUTION_STATUS_PAUSED,
105+
},
106+
},
107+
}, nil
108+
}
99109

100110
mutableState := workflowLease.GetMutableState()
101111
if !mutableState.IsWorkflowExecutionRunning() && !mutableState.HasCompletedAnyWorkflowTask() {

tests/pause_workflow_execution_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func (s *PauseWorkflowExecutionSuite) TestQueryWorkflowWhenPaused() {
165165
}
166166
}, 5*time.Second, 200*time.Millisecond)
167167

168-
// Issue a query with reject condition so that paused workflows return QueryRejected with PAUSED status.
168+
// Issue a query to the paused workflow. It should return QueryRejected with WORKFLOW_EXECUTION_STATUS_PAUSED status.
169169
queryReq := &workflowservice.QueryWorkflowRequest{
170170
Namespace: s.Namespace().String(),
171171
Execution: &commonpb.WorkflowExecution{
@@ -175,7 +175,6 @@ func (s *PauseWorkflowExecutionSuite) TestQueryWorkflowWhenPaused() {
175175
Query: &querypb.WorkflowQuery{
176176
QueryType: "__stack_trace",
177177
},
178-
QueryRejectCondition: enumspb.QUERY_REJECT_CONDITION_NOT_OPEN,
179178
}
180179
queryResp, err := s.FrontendClient().QueryWorkflow(ctx, queryReq)
181180
s.NoError(err)

0 commit comments

Comments
 (0)