From 40aa0df73e77e1128e85af6ff8f2a8f8ad287bc4 Mon Sep 17 00:00:00 2001 From: David Reiss Date: Wed, 6 Sep 2023 11:39:45 -0700 Subject: [PATCH] Make versioning data limits configurable by namespace --- service/matching/config.go | 12 ++++++------ service/matching/matching_engine.go | 14 +++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/service/matching/config.go b/service/matching/config.go index e913268b15e..7c1cadc88b6 100644 --- a/service/matching/config.go +++ b/service/matching/config.go @@ -63,9 +63,9 @@ type ( ForwarderMaxOutstandingTasks dynamicconfig.IntPropertyFnWithTaskQueueInfoFilters ForwarderMaxRatePerSecond dynamicconfig.IntPropertyFnWithTaskQueueInfoFilters ForwarderMaxChildrenPerNode dynamicconfig.IntPropertyFnWithTaskQueueInfoFilters - VersionCompatibleSetLimitPerQueue dynamicconfig.IntPropertyFn - VersionBuildIdLimitPerQueue dynamicconfig.IntPropertyFn - TaskQueueLimitPerBuildId dynamicconfig.IntPropertyFn + VersionCompatibleSetLimitPerQueue dynamicconfig.IntPropertyFnWithNamespaceFilter + VersionBuildIdLimitPerQueue dynamicconfig.IntPropertyFnWithNamespaceFilter + TaskQueueLimitPerBuildId dynamicconfig.IntPropertyFnWithNamespaceFilter GetUserDataLongPollTimeout dynamicconfig.DurationPropertyFn // Time to hold a poll request before returning an empty response if there are no tasks @@ -183,9 +183,9 @@ func NewConfig( ForwarderMaxRatePerSecond: dc.GetIntPropertyFilteredByTaskQueueInfo(dynamicconfig.MatchingForwarderMaxRatePerSecond, 10), ForwarderMaxChildrenPerNode: dc.GetIntPropertyFilteredByTaskQueueInfo(dynamicconfig.MatchingForwarderMaxChildrenPerNode, 20), ShutdownDrainDuration: dc.GetDurationProperty(dynamicconfig.MatchingShutdownDrainDuration, 0*time.Second), - VersionCompatibleSetLimitPerQueue: dc.GetIntProperty(dynamicconfig.VersionCompatibleSetLimitPerQueue, 10), - VersionBuildIdLimitPerQueue: dc.GetIntProperty(dynamicconfig.VersionBuildIdLimitPerQueue, 100), - TaskQueueLimitPerBuildId: dc.GetIntProperty(dynamicconfig.TaskQueuesPerBuildIdLimit, 20), + VersionCompatibleSetLimitPerQueue: dc.GetIntPropertyFilteredByNamespace(dynamicconfig.VersionCompatibleSetLimitPerQueue, 10), + VersionBuildIdLimitPerQueue: dc.GetIntPropertyFilteredByNamespace(dynamicconfig.VersionBuildIdLimitPerQueue, 100), + TaskQueueLimitPerBuildId: dc.GetIntPropertyFilteredByNamespace(dynamicconfig.TaskQueuesPerBuildIdLimit, 20), GetUserDataLongPollTimeout: dc.GetDurationProperty(dynamicconfig.MatchingGetUserDataLongPollTimeout, 5*time.Minute), AdminNamespaceToPartitionDispatchRate: dc.GetFloatPropertyFilteredByNamespace(dynamicconfig.AdminMatchingNamespaceToPartitionDispatchRate, 10000), diff --git a/service/matching/matching_engine.go b/service/matching/matching_engine.go index 4ba0b62666f..b9f49b2c26d 100644 --- a/service/matching/matching_engine.go +++ b/service/matching/matching_engine.go @@ -832,6 +832,10 @@ func (e *matchingEngineImpl) UpdateWorkerBuildIdCompatibility( req *matchingservice.UpdateWorkerBuildIdCompatibilityRequest, ) (*matchingservice.UpdateWorkerBuildIdCompatibilityResponse, error) { namespaceID := namespace.ID(req.GetNamespaceId()) + ns, err := e.namespaceRegistry.GetNamespaceByID(namespaceID) + if err != nil { + return nil, err + } taskQueueName := req.GetTaskQueue() taskQueue, err := newTaskQueueID(namespaceID, taskQueueName, enumspb.TASK_QUEUE_TYPE_WORKFLOW) if err != nil { @@ -846,7 +850,7 @@ func (e *matchingEngineImpl) UpdateWorkerBuildIdCompatibility( switch req.GetOperation().(type) { case *matchingservice.UpdateWorkerBuildIdCompatibilityRequest_ApplyPublicRequest_: // Only apply the limit when request is initiated by a user. - updateOptions.TaskQueueLimitPerBuildId = e.config.TaskQueueLimitPerBuildId() + updateOptions.TaskQueueLimitPerBuildId = e.config.TaskQueueLimitPerBuildId(ns.Name().String()) case *matchingservice.UpdateWorkerBuildIdCompatibilityRequest_RemoveBuildIds_: updateOptions.KnownVersion = req.GetRemoveBuildIds().GetKnownUserDataVersion() } @@ -866,17 +870,13 @@ func (e *matchingEngineImpl) UpdateWorkerBuildIdCompatibility( updatedClock, data.GetVersioningData(), req.GetApplyPublicRequest().GetRequest(), - e.config.VersionCompatibleSetLimitPerQueue(), - e.config.VersionBuildIdLimitPerQueue(), + e.config.VersionCompatibleSetLimitPerQueue(ns.Name().String()), + e.config.VersionBuildIdLimitPerQueue(ns.Name().String()), ) if err != nil { return nil, false, err } case *matchingservice.UpdateWorkerBuildIdCompatibilityRequest_RemoveBuildIds_: - ns, err := e.namespaceRegistry.GetNamespaceByID(namespaceID) - if err != nil { - return nil, false, err - } versioningData = RemoveBuildIds( updatedClock, data.GetVersioningData(),