@@ -53,6 +53,7 @@ import (
5353 "go.temporal.io/server/common/resource"
5454 "go.temporal.io/server/common/searchattribute"
5555 serviceerrors "go.temporal.io/server/common/serviceerror"
56+ "go.temporal.io/server/common/softassert"
5657 "go.temporal.io/server/common/stream_batcher"
5758 "go.temporal.io/server/common/taskqueue"
5859 "go.temporal.io/server/common/tasktoken"
@@ -67,7 +68,7 @@ import (
6768)
6869
6970const (
70- // If sticky poller is not seem in last 10s, we treat it as sticky worker unavailable
71+ // If sticky poller is not seen in last 10s, we treat it as sticky worker unavailable.
7172 // This seems aggressive, but the default sticky schedule_to_start timeout is 5s, so 10s seems reasonable.
7273 stickyPollerUnavailableWindow = 10 * time .Second
7374
@@ -570,13 +571,16 @@ func (e *matchingEngineImpl) AddWorkflowTask(
570571 if err != nil {
571572 return "" , false , err
572573 }
574+ if ! softassert .That (e .logger , partition .Kind () == enumspb .TASK_QUEUE_KIND_NORMAL || partition .Kind () == enumspb .TASK_QUEUE_KIND_STICKY , //nolint:forbidigo
575+ "AddWorkflowTask called with unexpected partition kind" ) {
576+ return "" , false , serviceerror .NewInternal ("AddWorkflowTask called with unexpected partition kind" )
577+ }
573578
574- ephemeral := partition .IsEphemeral ()
575579 // do not load ephemeral task queue if it is not already loaded, which means it has no poller.
576- pm , _ , err := e .getTaskQueuePartitionManager (ctx , partition , ! ephemeral , loadCauseTask )
580+ pm , _ , err := e .getTaskQueuePartitionManager (ctx , partition , ! partition . IsEphemeral () , loadCauseTask )
577581 if err != nil {
578582 return "" , false , err
579- } else if ephemeral && ! stickyWorkerAvailable (pm ) {
583+ } else if partition . Kind () == enumspb . TASK_QUEUE_KIND_STICKY && ! stickyWorkerAvailable (pm ) {
580584 return "" , false , serviceerrors .NewStickyWorkerUnavailable ()
581585 }
582586
@@ -1089,12 +1093,15 @@ func (e *matchingEngineImpl) QueryWorkflow(
10891093 if err != nil {
10901094 return nil , err
10911095 }
1092- ephemeral := partition .IsEphemeral ()
1096+ if ! softassert .That (e .logger , partition .Kind () == enumspb .TASK_QUEUE_KIND_NORMAL || partition .Kind () == enumspb .TASK_QUEUE_KIND_STICKY , //nolint:forbidigo
1097+ "QueryWorkflow called with unexpected partition kind" ) {
1098+ return nil , serviceerror .NewInternal ("QueryWorkflow called with unexpected partition kind" )
1099+ }
10931100 // do not load ephemeral task queue if it is not already loaded, which means it has no poller.
1094- pm , _ , err := e .getTaskQueuePartitionManager (ctx , partition , ! ephemeral , loadCauseQuery )
1101+ pm , _ , err := e .getTaskQueuePartitionManager (ctx , partition , ! partition . IsEphemeral () , loadCauseQuery )
10951102 if err != nil {
10961103 return nil , err
1097- } else if ephemeral && ! stickyWorkerAvailable (pm ) {
1104+ } else if partition . Kind () == enumspb . TASK_QUEUE_KIND_STICKY && ! stickyWorkerAvailable (pm ) {
10981105 return nil , serviceerrors .NewStickyWorkerUnavailable ()
10991106 }
11001107
0 commit comments