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

handle error when loading empty build ids keywordlist #6897

Closed
wants to merge 3 commits into from
Closed
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
12 changes: 8 additions & 4 deletions service/history/workflow/mutable_state_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2678,11 +2678,15 @@ func (ms *MutableStateImpl) loadBuildIds() ([]string, error) {
if err != nil {
return nil, err
}
searchAttributeValues, ok := decoded.([]string)
if !ok {
return nil, serviceerror.NewInternal("invalid search attribute value stored for BuildIds")
if decoded != nil {
searchAttributeValues, ok := decoded.([]string)
if !ok {
return nil, serviceerror.NewInternal("invalid search attribute value stored for BuildIds")
}
return searchAttributeValues, nil
}
return searchAttributeValues, nil
return make([]string, 0), nil

}

// getPinnedDeployment returns nil if the workflow is not pinned. If there is a pinned override,
Expand Down
76 changes: 13 additions & 63 deletions service/history/workflow/mutable_state_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
"go.uber.org/mock/gomock"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/fieldmaskpb"
"google.golang.org/protobuf/types/known/timestamppb"

commandpb "go.temporal.io/api/command/v1"
Expand Down Expand Up @@ -127,13 +126,6 @@ var (
SeriesName: "my_app",
BuildId: "build_3",
}
versionOverrideMask = &fieldmaskpb.FieldMask{Paths: []string{"versioning_behavior_override"}}
pinnedOptions1 = &workflowpb.WorkflowExecutionOptions{
VersioningOverride: &workflowpb.VersioningOverride{
Behavior: enumspb.VERSIONING_BEHAVIOR_PINNED,
Deployment: deployment1,
},
}
pinnedOptions2 = &workflowpb.WorkflowExecutionOptions{
VersioningOverride: &workflowpb.VersioningOverride{
Behavior: enumspb.VERSIONING_BEHAVIOR_PINNED,
Expand All @@ -151,12 +143,7 @@ var (
Behavior: enumspb.VERSIONING_BEHAVIOR_AUTO_UPGRADE,
},
}
unspecifiedOptions = &workflowpb.WorkflowExecutionOptions{
VersioningOverride: &workflowpb.VersioningOverride{
Behavior: enumspb.VERSIONING_BEHAVIOR_UNSPECIFIED,
},
}
emptyOptions = &workflowpb.WorkflowExecutionOptions{} // should be handled the same as unspecifiedOptions
emptyOptions = &workflowpb.WorkflowExecutionOptions{}
)

func TestMutableStateSuite(t *testing.T) {
Expand Down Expand Up @@ -843,12 +830,17 @@ func (s *mutableStateSuite) verifyOverrides(
) {
versioningInfo := s.mutableState.GetExecutionInfo().GetVersioningInfo()
s.Equal(expectedBehavior, versioningInfo.Behavior)
s.Equal(expectedBehaviorOverride, versioningInfo.VersioningOverride.Behavior)
s.Equal(expectedDeployment, versioningInfo.Deployment)
s.Equal(expectedDeploymentOverride, versioningInfo.VersioningOverride.Deployment)
if versioningInfo.VersioningOverride == nil {
s.Equal(enumspb.VERSIONING_BEHAVIOR_UNSPECIFIED, expectedBehaviorOverride)
s.Nil(expectedDeploymentOverride)
} else {
s.Equal(expectedBehaviorOverride, versioningInfo.VersioningOverride.Behavior)
s.Equal(expectedDeploymentOverride, versioningInfo.VersioningOverride.Deployment)
}
}

func (s *mutableStateSuite) TestOverride_UnpinnedBase_SetPinnedAndUnsetWithEmptyOptions() {
func (s *mutableStateSuite) TestOverride_UnpinnedBase_SetPinnedAndUnset() {
tq := &taskqueuepb.TaskQueue{Name: "tq"}
baseBehavior := enumspb.VERSIONING_BEHAVIOR_AUTO_UPGRADE
overrideBehavior := enumspb.VERSIONING_BEHAVIOR_PINNED
Expand All @@ -869,28 +861,7 @@ func (s *mutableStateSuite) TestOverride_UnpinnedBase_SetPinnedAndUnsetWithEmpty
s.verifyOverrides(baseBehavior, enumspb.VERSIONING_BEHAVIOR_UNSPECIFIED, deployment1, nil)
}

func (s *mutableStateSuite) TestOverride_UnpinnedBase_SetPinnedAndUnsetWithUnspecifiedOptions() {
tq := &taskqueuepb.TaskQueue{Name: "tq"}
baseBehavior := enumspb.VERSIONING_BEHAVIOR_AUTO_UPGRADE
overrideBehavior := enumspb.VERSIONING_BEHAVIOR_PINNED
s.createMutableStateWithVersioningBehavior(baseBehavior, deployment1, tq)

// set pinned override
event, err := s.mutableState.AddWorkflowExecutionOptionsUpdatedEvent(pinnedOptions2.GetVersioningOverride())
s.NoError(err)
s.verifyEffectiveDeployment(deployment2, overrideBehavior)
s.verifyWorkflowOptionsUpdatedEvent(event, pinnedOptions2.GetVersioningOverride())
s.verifyOverrides(baseBehavior, overrideBehavior, deployment1, deployment2)

// unset pinned override with unspecified
event, err = s.mutableState.AddWorkflowExecutionOptionsUpdatedEvent(unspecifiedOptions.GetVersioningOverride())
s.NoError(err)
s.verifyEffectiveDeployment(deployment1, baseBehavior)
s.verifyWorkflowOptionsUpdatedEvent(event, unspecifiedOptions.GetVersioningOverride())
s.verifyOverrides(baseBehavior, enumspb.VERSIONING_BEHAVIOR_UNSPECIFIED, deployment1, nil)
}

func (s *mutableStateSuite) TestOverride_PinnedBase_SetUnpinnedAndUnsetWithEmptyOptions() {
func (s *mutableStateSuite) TestOverride_PinnedBase_SetUnpinnedAndUnset() {
tq := &taskqueuepb.TaskQueue{Name: "tq"}
baseBehavior := enumspb.VERSIONING_BEHAVIOR_PINNED
overrideBehavior := enumspb.VERSIONING_BEHAVIOR_AUTO_UPGRADE
Expand All @@ -903,35 +874,14 @@ func (s *mutableStateSuite) TestOverride_PinnedBase_SetUnpinnedAndUnsetWithEmpty
s.verifyWorkflowOptionsUpdatedEvent(event, unpinnedOptions.GetVersioningOverride())
s.verifyOverrides(baseBehavior, overrideBehavior, deployment1, nil)

// unset pinned override with empty
// unset unpinned override with empty
event, err = s.mutableState.AddWorkflowExecutionOptionsUpdatedEvent(emptyOptions.GetVersioningOverride())
s.NoError(err)
s.verifyEffectiveDeployment(deployment1, baseBehavior)
s.verifyWorkflowOptionsUpdatedEvent(event, emptyOptions.GetVersioningOverride())
s.verifyOverrides(baseBehavior, enumspb.VERSIONING_BEHAVIOR_UNSPECIFIED, deployment1, nil)
}

func (s *mutableStateSuite) TestOverride_PinnedBase_SetUnpinnedAndUnsetWithUnspecifiedOptions() {
tq := &taskqueuepb.TaskQueue{Name: "tq"}
baseBehavior := enumspb.VERSIONING_BEHAVIOR_PINNED
overrideBehavior := enumspb.VERSIONING_BEHAVIOR_AUTO_UPGRADE
s.createMutableStateWithVersioningBehavior(baseBehavior, deployment1, tq)

// set unpinned override
event, err := s.mutableState.AddWorkflowExecutionOptionsUpdatedEvent(unpinnedOptions.GetVersioningOverride())
s.NoError(err)
s.verifyEffectiveDeployment(deployment1, overrideBehavior)
s.verifyWorkflowOptionsUpdatedEvent(event, unpinnedOptions.GetVersioningOverride())
s.verifyOverrides(baseBehavior, overrideBehavior, deployment1, nil)

// unset pinned override with unspecified
event, err = s.mutableState.AddWorkflowExecutionOptionsUpdatedEvent(unspecifiedOptions.GetVersioningOverride())
s.NoError(err)
s.verifyEffectiveDeployment(deployment1, baseBehavior)
s.verifyWorkflowOptionsUpdatedEvent(event, unspecifiedOptions.GetVersioningOverride())
s.verifyOverrides(baseBehavior, enumspb.VERSIONING_BEHAVIOR_UNSPECIFIED, deployment1, nil)
}

func (s *mutableStateSuite) TestOverride_RedirectFails() {
tq := &taskqueuepb.TaskQueue{Name: "tq"}
baseBehavior := enumspb.VERSIONING_BEHAVIOR_AUTO_UPGRADE
Expand Down Expand Up @@ -1001,10 +951,10 @@ func (s *mutableStateSuite) TestOverride_BaseDeploymentUpdatedOnCompletion() {
s.verifyOverrides(baseBehavior, overrideBehavior, deployment2, deployment3)

// now we unset the override and check that the base deployment/behavior is in effect
event, err = s.mutableState.AddWorkflowExecutionOptionsUpdatedEvent(unspecifiedOptions.GetVersioningOverride())
event, err = s.mutableState.AddWorkflowExecutionOptionsUpdatedEvent(emptyOptions.GetVersioningOverride())
s.NoError(err)
s.verifyEffectiveDeployment(deployment2, baseBehavior)
s.verifyWorkflowOptionsUpdatedEvent(event, unspecifiedOptions.GetVersioningOverride())
s.verifyWorkflowOptionsUpdatedEvent(event, emptyOptions.GetVersioningOverride())
s.verifyOverrides(baseBehavior, enumspb.VERSIONING_BEHAVIOR_UNSPECIFIED, deployment2, nil)
}

Expand Down
Loading