Skip to content

Commit

Permalink
Do not make poller crash if isolation group is invalid (cadence-workf…
Browse files Browse the repository at this point in the history
…low#5372)

Co-authored-by: David Porter <[email protected]>
  • Loading branch information
Shaddoll and davidporter-id-au authored Aug 2, 2023
1 parent b432226 commit 1202a2e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions common/metrics/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2329,6 +2329,7 @@ const (
RemoteToRemoteMatchPerTaskListCounter
IsolationTaskMatchPerTaskListCounter
PollerPerTaskListCounter
PollerInvalidIsolationGroupCounter
TaskListManagersGauge
TaskLagPerTaskListGauge
TaskBacklogPerTaskListGauge
Expand Down Expand Up @@ -2930,6 +2931,7 @@ var MetricDefs = map[ServiceIdx]map[int]metricDefinition{
RemoteToRemoteMatchPerTaskListCounter: {metricName: "remote_to_remote_matches_per_tl", metricRollupName: "remote_to_remote_matches"},
IsolationTaskMatchPerTaskListCounter: {metricName: "isolation_task_matches_per_tl", metricType: Counter},
PollerPerTaskListCounter: {metricName: "poller_count_per_tl", metricRollupName: "poller_count"},
PollerInvalidIsolationGroupCounter: {metricName: "poller_invalid_isolation_group_per_tl", metricType: Counter},
TaskListManagersGauge: {metricName: "tasklist_managers", metricType: Gauge},
TaskLagPerTaskListGauge: {metricName: "task_lag_per_tl", metricType: Gauge},
TaskBacklogPerTaskListGauge: {metricName: "task_backlog_per_tl", metricType: Gauge},
Expand Down
5 changes: 3 additions & 2 deletions service/matching/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ package matching
import (
"context"
"errors"
"fmt"
"time"

"golang.org/x/time/rate"
Expand Down Expand Up @@ -281,7 +280,9 @@ forLoop:
func (tm *TaskMatcher) Poll(ctx context.Context, isolationGroup string) (*InternalTask, error) {
isolatedTaskC, ok := tm.isolatedTaskC[isolationGroup]
if !ok && isolationGroup != "" {
return nil, &types.BadRequestError{Message: fmt.Sprintf("invalid isolation group: %s", isolationGroup)}
// fallback to default isolation group instead of making poller crash if the isolation group is invalid
isolatedTaskC = tm.taskC
tm.scope.IncCounter(metrics.PollerInvalidIsolationGroupCounter)
}
// try local match first without blocking until context timeout
if task, err := tm.pollNonBlocking(ctx, isolatedTaskC, tm.taskC, tm.queryTaskC); err == nil {
Expand Down

0 comments on commit 1202a2e

Please sign in to comment.