Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove build id from sticky recordWorkflowTaskStarted #6096

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions service/history/api/respondworkflowtaskcompleted/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,9 @@ func (handler *WorkflowTaskCompletedHandler) Invoke(
return nil, serviceerror.NewNotFound("Workflow task not found.")
}

if assignedBuildId := ms.GetAssignedBuildId(); assignedBuildId != "" {
// worker versioning is used, make sure the task was completed by the right build ID
if assignedBuildId := ms.GetAssignedBuildId(); assignedBuildId != "" && !ms.IsStickyTaskQueueSet() {
// Worker versioning is used, make sure the task was completed by the right build ID, unless we're using a
// sticky queue in which case Matching will not send the build ID
wftStartedBuildId := ms.GetExecutionInfo().GetWorkflowTaskBuildId()
wftCompletedBuildId := request.GetWorkerVersionStamp().GetBuildId()
if wftCompletedBuildId != wftStartedBuildId {
Expand Down
6 changes: 5 additions & 1 deletion service/matching/version_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,11 @@ func checkVersionForStickyPoll(data *persistencespb.VersioningData, caps *common
// A poller is using a build ID, but we don't know about that build ID. See comments in
// lookupVersionSetForPoll. If we consider it the default for its set, then we should
// leave it on the sticky queue here.
return false, nil
// We set return true for all sticky tasks until old versioning is cleaned up.
// this value is used by matching_engine for deciding if it should pass the worker build ID
// to history in the recordStart call or not. We don't need to pass build ID for sticky
// tasks as no redirect happen in a sticky queue.
return true, nil
}
set := data.VersionSets[setIdx]
lastIndex := len(set.BuildIds) - 1
Expand Down
81 changes: 54 additions & 27 deletions tests/versioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,13 @@ func (s *VersioningIntegSuite) workflowStaysInBuildId() {
s.NoError(run.Get(ctx, &out))
s.Equal("done!", out)
s.validateWorkflowBuildIds(ctx, run.GetID(), run.GetRunID(), v1, true, v1, "", nil)
s.validateWorkflowEventsVersionStamps(ctx, run.GetID(), run.GetRunID(), []string{v1, v1, v1, v1, v1}, "")
s.validateWorkflowEventsVersionStamps(ctx, run.GetID(), run.GetRunID(), []string{
v1, // WFT
v1, // activity
// v1, skipped because it belongs to sticky queue
v1, // activity
// v1, skipped because it belongs to sticky queue
}, "")
}

func (s *VersioningIntegSuite) TestUnversionedWorkflowStaysUnversioned() {
Expand Down Expand Up @@ -1182,17 +1188,23 @@ func (s *VersioningIntegSuite) independentActivityTaskAssignmentSpooled(versione
s.NoError(run.Get(ctx, &out))
s.Equal("done!", out)

wfBuild := ""
if versionedWf {
wfBuild = wfV1
s.validateWorkflowEventsVersionStamps(
ctx, run.GetID(), run.GetRunID(), []string{
wfV1,
v3, // succeeded activity
// wfV1, removed because it's on a sticky queue
}, "",
)
} else {
s.validateWorkflowEventsVersionStamps(
ctx, run.GetID(), run.GetRunID(), []string{
"",
v3, // succeeded activity
"",
}, "",
)
}
s.validateWorkflowEventsVersionStamps(
ctx, run.GetID(), run.GetRunID(), []string{
wfBuild,
v3, // succeeded activity
wfBuild,
}, "",
)
}

func (s *VersioningIntegSuite) TestIndependentActivityTaskAssignment_SyncMatch_VersionedWorkflow() {
Expand Down Expand Up @@ -1354,18 +1366,25 @@ func (s *VersioningIntegSuite) independentActivityTaskAssignmentSyncMatch(versio
s.NoError(run.Get(ctx, &out))
s.Equal("done!", out)

wfBuild := ""
if versionedWf {
wfBuild = wfV1
s.validateWorkflowBuildIds(ctx, run.GetID(), run.GetRunID(), wfV1, true, wfV1, "", nil)
s.validateWorkflowEventsVersionStamps(
ctx, run.GetID(), run.GetRunID(), []string{
wfV1,
v3, // succeeded activity
// wfV1, skipping stamp because this is a sticky queue task
}, "",
)
} else {
s.validateWorkflowBuildIds(ctx, run.GetID(), run.GetRunID(), "", true, wfV1, "", nil)
s.validateWorkflowEventsVersionStamps(
ctx, run.GetID(), run.GetRunID(), []string{
"",
v3, // succeeded activity
"",
}, "",
)
}
s.validateWorkflowBuildIds(ctx, run.GetID(), run.GetRunID(), wfBuild, true, wfV1, "", nil)
s.validateWorkflowEventsVersionStamps(
ctx, run.GetID(), run.GetRunID(), []string{
wfBuild,
v3, // succeeded activity
wfBuild,
}, "",
)
}

func (s *VersioningIntegSuite) TestWorkflowTaskRedirectInRetryFirstTask() {
Expand Down Expand Up @@ -1516,9 +1535,9 @@ func (s *VersioningIntegSuite) testWorkflowTaskRedirectInRetry(firstTask bool) {
}
if !firstTask {
expectedStamps = []string{
v1, // first wf task
v1, // activity task
v1, // failed wf task on sticky queue
v1, // first wf task
v1, // activity task
// v1, // skipping stamp for failed wf task on sticky queue
v1, // failed wf task on normal queue
v11, // timed out wf task show up in history because they happened on a different build ID
v12, // succeeded wf task
Expand Down Expand Up @@ -2300,9 +2319,12 @@ func (s *VersioningIntegSuite) TestRedirectWithConcurrentActivities() {
activityPerVersion[buildId]--
} else if wfStarted := he.GetWorkflowTaskStartedEventAttributes(); wfStarted != nil {
taskStartedStamp = wfStarted.GetWorkerVersion()
s.True(taskStartedStamp.GetUseVersioning())
buildId = taskStartedStamp.GetBuildId()
taskRedirectCounter = wfStarted.GetBuildIdRedirectCounter()
if taskStartedStamp != nil {
// taskStartedStamp is nil for sticky queues
s.True(taskStartedStamp.GetUseVersioning())
buildId = taskStartedStamp.GetBuildId()
taskRedirectCounter = wfStarted.GetBuildIdRedirectCounter()
}
}
if he.EventTime.AsTime().Before(maxStartedTimestamp) {
sawUnorderedEvents = true
Expand Down Expand Up @@ -3904,7 +3926,12 @@ func (s *VersioningIntegSuite) validateBuildIdAfterReset(ctx context.Context, wf
s.NoError(run2.Get(ctx, &out))
s.Equal("done!", out)
s.validateWorkflowBuildIds(ctx, run2.GetID(), run2.GetRunID(), expectedBuildId, true, expectedBuildId, inheritedBuildId, nil)
s.validateWorkflowEventsVersionStamps(ctx, run2.GetID(), run2.GetRunID(), []string{expectedBuildId, expectedBuildId, expectedBuildId}, inheritedBuildId)
s.validateWorkflowEventsVersionStamps(ctx, run2.GetID(), run2.GetRunID(), []string{
expectedBuildId,
expectedBuildId,
// expectedBuildId, skipped because it belongs to a sticky queue
},
inheritedBuildId)

// now reset the original wf to second wf task and make sure it remains in v1
wfr, err = s.sdkClient.ResetWorkflowExecution(ctx, &workflowservice.ResetWorkflowExecutionRequest{
Expand Down
Loading