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

Queue refactor part 2: task generation #2479

Merged
merged 7 commits into from
Feb 10, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 3 additions & 12 deletions common/persistence/dataInterfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,7 @@ type (
WorkflowID string
RunID string

TransferTasks []tasks.Task
TimerTasks []tasks.Task
ReplicationTasks []tasks.Task
VisibilityTasks []tasks.Task
Tasks map[tasks.Category][]tasks.Task
}

// CreateWorkflowExecutionRequest is used to write a new workflow execution
Expand Down Expand Up @@ -363,10 +360,7 @@ type (
NewBufferedEvents []*historypb.HistoryEvent
ClearBufferedEvents bool

TransferTasks []tasks.Task
ReplicationTasks []tasks.Task
TimerTasks []tasks.Task
VisibilityTasks []tasks.Task
Tasks map[tasks.Category][]tasks.Task

// TODO deprecate Condition in favor of DBRecordVersion
Condition int64
Expand All @@ -388,10 +382,7 @@ type (
SignalInfos map[int64]*persistencespb.SignalInfo
SignalRequestedIDs map[string]struct{}

TransferTasks []tasks.Task
ReplicationTasks []tasks.Task
TimerTasks []tasks.Task
VisibilityTasks []tasks.Task
Tasks map[tasks.Category][]tasks.Task

// TODO deprecate Condition in favor of DBRecordVersion
Condition int64
Expand Down
25 changes: 13 additions & 12 deletions common/persistence/execution_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
"go.temporal.io/server/common/log/tag"
"go.temporal.io/server/common/persistence/serialization"
"go.temporal.io/server/common/persistence/versionhistory"
"go.temporal.io/server/service/history/tasks"
)

type (
Expand Down Expand Up @@ -426,19 +427,19 @@ func (m *executionManagerImpl) SerializeWorkflowMutation(

var err error

transferTasks, err := m.serializer.SerializeTransferTasks(input.TransferTasks)
transferTasks, err := m.serializer.SerializeTransferTasks(input.Tasks[tasks.CategoryTransfer])
yycptt marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return nil, err
}
timerTasks, err := m.serializer.SerializeTimerTasks(input.TimerTasks)
timerTasks, err := m.serializer.SerializeTimerTasks(input.Tasks[tasks.CategoryTimer])
if err != nil {
return nil, err
}
replicationTasks, err := m.serializer.SerializeReplicationTasks(input.ReplicationTasks)
replicationTasks, err := m.serializer.SerializeReplicationTasks(input.Tasks[tasks.CategoryReplication])
if err != nil {
return nil, err
}
visibilityTasks, err := m.serializer.SerializeVisibilityTasks(input.VisibilityTasks)
visibilityTasks, err := m.serializer.SerializeVisibilityTasks(input.Tasks[tasks.CategoryVisibility])
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -545,19 +546,19 @@ func (m *executionManagerImpl) SerializeWorkflowSnapshot(

var err error

transferTasks, err := m.serializer.SerializeTransferTasks(input.TransferTasks)
transferTasks, err := m.serializer.SerializeTransferTasks(input.Tasks[tasks.CategoryTransfer])
if err != nil {
return nil, err
}
timerTasks, err := m.serializer.SerializeTimerTasks(input.TimerTasks)
timerTasks, err := m.serializer.SerializeTimerTasks(input.Tasks[tasks.CategoryTimer])
if err != nil {
return nil, err
}
replicationTasks, err := m.serializer.SerializeReplicationTasks(input.ReplicationTasks)
replicationTasks, err := m.serializer.SerializeReplicationTasks(input.Tasks[tasks.CategoryReplication])
if err != nil {
return nil, err
}
visibilityTasks, err := m.serializer.SerializeVisibilityTasks(input.VisibilityTasks)
visibilityTasks, err := m.serializer.SerializeVisibilityTasks(input.Tasks[tasks.CategoryVisibility])
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -700,19 +701,19 @@ func (m *executionManagerImpl) AddTasks(
input *AddTasksRequest,
) error {

transferTasks, err := m.serializer.SerializeTransferTasks(input.TransferTasks)
transferTasks, err := m.serializer.SerializeTransferTasks(input.Tasks[tasks.CategoryTransfer])
if err != nil {
return err
}
timerTasks, err := m.serializer.SerializeTimerTasks(input.TimerTasks)
timerTasks, err := m.serializer.SerializeTimerTasks(input.Tasks[tasks.CategoryTimer])
if err != nil {
return err
}
replicationTasks, err := m.serializer.SerializeReplicationTasks(input.ReplicationTasks)
replicationTasks, err := m.serializer.SerializeReplicationTasks(input.Tasks[tasks.CategoryReplication])
if err != nil {
return err
}
visibilityTasks, err := m.serializer.SerializeVisibilityTasks(input.VisibilityTasks)
visibilityTasks, err := m.serializer.SerializeVisibilityTasks(input.Tasks[tasks.CategoryVisibility])
if err != nil {
return err
}
Expand Down
15 changes: 8 additions & 7 deletions common/persistence/persistence-tests/executionManagerTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -1055,15 +1055,16 @@ func (s *ExecutionManagerSuite) TestPersistenceStartWorkflow() {
Status: enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
},
NextEventID: int64(3),
TransferTasks: []tasks.Task{
&tasks.WorkflowTask{
WorkflowKey: workflowKey,
TaskID: s.GetNextSequenceNumber(),
TaskQueue: "queue1",
ScheduleID: int64(2),
Tasks: map[tasks.Category][]tasks.Task{
tasks.CategoryTransfer: {
&tasks.WorkflowTask{
WorkflowKey: workflowKey,
TaskID: s.GetNextSequenceNumber(),
TaskQueue: "queue1",
ScheduleID: int64(2),
},
},
},
TimerTasks: nil,
},
RangeID: s.ShardInfo.GetRangeId() - 1,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,18 @@ func (s *ExecutionManagerSuiteForEventsV2) TestWorkflowCreation() {
State: enumsspb.WORKFLOW_EXECUTION_STATE_RUNNING,
Status: enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
},
TransferTasks: []tasks.Task{
&tasks.WorkflowTask{
WorkflowKey: workflowKey,
TaskID: s.GetNextSequenceNumber(),
TaskQueue: "taskQueue",
ScheduleID: 2,
VisibilityTimestamp: time.Now().UTC(),
Tasks: map[tasks.Category][]tasks.Task{
tasks.CategoryTransfer: {
&tasks.WorkflowTask{
WorkflowKey: workflowKey,
TaskID: s.GetNextSequenceNumber(),
TaskQueue: "taskQueue",
ScheduleID: 2,
VisibilityTimestamp: time.Now().UTC(),
},
},
},
TimerTasks: nil,
Checksum: csum,
Checksum: csum,
},
RangeID: s.ShardInfo.GetRangeId(),
})
Expand Down Expand Up @@ -239,21 +240,22 @@ func (s *ExecutionManagerSuiteForEventsV2) TestWorkflowCreationWithVersionHistor
Status: enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
},
NextEventID: common.EmptyEventID,
TransferTasks: []tasks.Task{
&tasks.WorkflowTask{
WorkflowKey: definition.NewWorkflowKey(
namespaceID,
workflowExecution.WorkflowId,
workflowExecution.RunId,
),
TaskID: s.GetNextSequenceNumber(),
TaskQueue: "taskQueue",
ScheduleID: 2,
VisibilityTimestamp: time.Now().UTC(),
Tasks: map[tasks.Category][]tasks.Task{
tasks.CategoryTransfer: {
&tasks.WorkflowTask{
WorkflowKey: definition.NewWorkflowKey(
namespaceID,
workflowExecution.WorkflowId,
workflowExecution.RunId,
),
TaskID: s.GetNextSequenceNumber(),
TaskQueue: "taskQueue",
ScheduleID: 2,
VisibilityTimestamp: time.Now().UTC(),
},
},
},
TimerTasks: nil,
Checksum: csum,
Checksum: csum,
},
})

Expand Down Expand Up @@ -340,11 +342,12 @@ func (s *ExecutionManagerSuiteForEventsV2) TestContinueAsNew() {
_, err2 := s.ExecutionManager.UpdateWorkflowExecution(&p.UpdateWorkflowExecutionRequest{
ShardID: s.ShardInfo.GetShardId(),
UpdateWorkflowMutation: p.WorkflowMutation{
ExecutionInfo: updatedInfo,
ExecutionState: updatedState,
NextEventID: int64(5),
TransferTasks: []tasks.Task{newworkflowTask},
TimerTasks: nil,
ExecutionInfo: updatedInfo,
ExecutionState: updatedState,
NextEventID: int64(5),
Tasks: map[tasks.Category][]tasks.Task{
tasks.CategoryTransfer: {newworkflowTask},
},
Condition: state0.NextEventId,
UpsertActivityInfos: nil,
DeleteActivityInfos: nil,
Expand All @@ -371,9 +374,8 @@ func (s *ExecutionManagerSuiteForEventsV2) TestContinueAsNew() {
State: enumsspb.WORKFLOW_EXECUTION_STATE_RUNNING,
Status: enumspb.WORKFLOW_EXECUTION_STATUS_RUNNING,
},
NextEventID: state0.NextEventId,
TransferTasks: nil,
TimerTasks: nil,
NextEventID: state0.NextEventId,
Tasks: map[tasks.Category][]tasks.Task{},
},
RangeID: s.ShardInfo.GetRangeId(),
})
Expand Down