Files
tasks/service/matching/deployment_util.go
Shahab TajikandGitHub 7dd52ee852 Handle independent activities of unpinned workflows + more tests (#6917)
## What changed?
<!-- Describe what has changed in this PR -->
Adding a check in `RecordActivityTaskStarted` to make sure the workflow
TQ's current deployment is the samewith the activity poller's deployment
before starting to transition the workflow. (The check is only
applicable when poller's deployment is different from the workflows
effective deployment).

## Why?
<!-- Tell your future self why have you made these changes -->
Activities belonging to different deployments are versioned
independently and should start on the current deployment of their task
queues without interference with versioning of the workflow. **Before
this change, the workflow would be stuck in a busy loop of activity and
workflow tasks,** because activity started a transition to it's own
deployment but then the next wf task would change the transition to it's
own deployment and reschedule the activity.

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
Added functional test.

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
None. This only affects workflows who use versioning 3. The single place
in the code that is changed is within `if` blocks that can activate only
when workflows/workers are using versioning 3.

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
Yes. Ideally should be added to the release 125 because other wise
workflows who use versioning 3 and also run activities belonging to TQs
in other deployments will generate explosive load to server and user's
workers.
2024-12-02 11:51:37 -08:00

46 lines
1.8 KiB
Go

// The MIT License
//
// Copyright (c) 2024 Temporal Technologies Inc. All rights reserved.
//
// Copyright (c) 2024 Uber Technologies, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
package matching
import (
deploymentpb "go.temporal.io/api/deployment/v1"
"go.temporal.io/api/serviceerror"
persistencespb "go.temporal.io/server/api/persistence/v1"
)
var (
errDeploymentsNotAllowed = serviceerror.NewPermissionDenied("deployments are disabled on this namespace", "")
errMissingDeployment = serviceerror.NewInvalidArgument("missing deployment")
)
func findDeployment(deployments *persistencespb.DeploymentData, deployment *deploymentpb.Deployment) int {
for i, d := range deployments.GetDeployments() {
if d.Deployment.SeriesName == deployment.SeriesName && d.Deployment.BuildId == deployment.BuildId {
return i
}
}
return -1
}