Fix NPE in task channelWeightFn
@@ -33,6 +33,7 @@ import (
"go.temporal.io/server/common/clock"
"go.temporal.io/server/common/dynamicconfig"
"go.temporal.io/server/common/log"
+ "go.temporal.io/server/common/log/tag"
"go.temporal.io/server/common/metrics"
"go.temporal.io/server/common/namespace"
"go.temporal.io/server/common/quotas"
@@ -114,14 +115,25 @@ func NewNamespacePriorityScheduler(
}
channelWeightFn := func(key TaskChannelKey) int {
namespaceWeights := options.ActiveNamespaceWeights
+ namespaceName := namespace.EmptyName
- namespace, _ := namespaceRegistry.GetNamespaceByID(namespace.ID(key.NamespaceID))
+ namespace, err := namespaceRegistry.GetNamespaceByID(namespace.ID(key.NamespaceID))
+ if err == nil {
+ namespaceName = namespace.Name()
if !namespace.ActiveInCluster(currentClusterName) {
namespaceWeights = options.StandbyNamespaceWeights
}
+ } else {
+ // if namespace not found, treat is as active namespace and
+ // use default active namespace weight
+ logger.Warn("Unable to find namespace, using active namespace task channel weight",
+ tag.WorkflowNamespaceID(key.NamespaceID),
+ tag.Error(err),
+ )
+ }
return configs.ConvertDynamicConfigValueToWeights(
- namespaceWeights(namespace.Name().String()),
+ namespaceWeights(namespaceName.String()),
logger,
)[key.Priority]
}
