Skip to content

Commit

Permalink
Enforce concurrent count limit to all long poll calls (#4120)
Browse files Browse the repository at this point in the history
  • Loading branch information
yiminc authored and hehaifengcn committed Mar 30, 2023
1 parent 4d5b279 commit 1a7b839
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 11 additions & 0 deletions common/rpc/interceptor/namespace_count_limit.go
Expand Up @@ -31,6 +31,7 @@ import (

enumspb "go.temporal.io/api/enums/v1"
"go.temporal.io/api/serviceerror"
"go.temporal.io/api/workflowservice/v1"
"google.golang.org/grpc"

"go.temporal.io/server/common/log"
Expand Down Expand Up @@ -81,6 +82,16 @@ func (ni *NamespaceCountLimitInterceptor) Intercept(
_, methodName := SplitMethodName(info.FullMethod)
// token will default to 0
token := ni.tokens[methodName]

if token != 0 {
// for GetWorkflowExecutionHistoryRequest, we only care about long poll requests
longPollReq, ok := req.(*workflowservice.GetWorkflowExecutionHistoryRequest)
if ok && !longPollReq.WaitNewEvent {
// ignore non-long-poll GetHistory calls.
token = 0
}
}

if token != 0 {
nsName := MustGetNamespaceName(ni.namespaceRegistry, req)
counter := ni.counter(nsName, methodName)
Expand Down
7 changes: 5 additions & 2 deletions service/frontend/configs/quotas.go
Expand Up @@ -33,8 +33,11 @@ import (

var (
ExecutionAPICountLimitOverride = map[string]int{
"PollActivityTaskQueue": 1,
"PollWorkflowTaskQueue": 1,
"PollActivityTaskQueue": 1,
"PollWorkflowTaskQueue": 1,
"QueryWorkflow": 1,
"UpdateWorkflowExecution": 1,
"GetWorkflowExecutionHistory": 1,
}

ExecutionAPIToPriority = map[string]int{
Expand Down

0 comments on commit 1a7b839

Please sign in to comment.