@@ -30,6 +30,7 @@ import (
3030 "go.temporal.io/server/common/persistence/visibility/manager"
3131 "go.temporal.io/server/common/searchattribute"
3232 "go.temporal.io/server/common/tasktoken"
33+ "go.temporal.io/server/common/worker_versioning"
3334 "go.temporal.io/server/service/history/api"
3435 "go.temporal.io/server/service/history/api/recordworkflowtaskstarted"
3536 "go.temporal.io/server/service/history/configs"
@@ -193,6 +194,7 @@ func (handler *WorkflowTaskCompletedHandler) Invoke(
193194 }
194195
195196 behavior := request .GetVersioningBehavior ()
197+ deployment := worker_versioning .DeploymentFromDeploymentVersion (worker_versioning .DeploymentVersionFromOptions (request .GetDeploymentOptions ()))
196198 //nolint:staticcheck // SA1019 deprecated Deployment will clean up later
197199 if behavior != enumspb .VERSIONING_BEHAVIOR_UNSPECIFIED && request .GetDeployment () == nil &&
198200 (request .GetDeploymentOptions () == nil || request .GetDeploymentOptions ().GetWorkerVersioningMode () != enumspb .WORKER_VERSIONING_MODE_VERSIONED ) {
@@ -306,7 +308,8 @@ func (handler *WorkflowTaskCompletedHandler) Invoke(
306308 metrics .CompleteWorkflowTaskWithStickyEnabledCounter .With (handler .metricsHandler ).Record (
307309 1 ,
308310 metrics .OperationTag (metrics .HistoryRespondWorkflowTaskCompletedScope ))
309- if assignedBuildId == "" || assignedBuildId == wftCompletedBuildId {
311+ if (assignedBuildId == "" || assignedBuildId == wftCompletedBuildId ) &&
312+ (ms .GetDeploymentTransition () == nil || ms .GetDeploymentTransition ().GetDeployment ().Equal (deployment )) {
310313 // TODO: clean up. this is not applicable to V3
311314 // For versioned workflows, only set sticky queue if the WFT is completed by the WF's current build ID.
312315 // It is possible that the WF has been redirected to another build ID since this WFT started, in that case
0 commit comments