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

Use the correct event version for task refresh #4349

Merged
merged 3 commits into from
May 16, 2023
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
1 change: 0 additions & 1 deletion service/history/api/refreshworkflow/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func Invoke(
shard,
shard.GetConfig(),
shard.GetNamespaceRegistry(),
shard.GetEventsCache(),
shard.GetLogger(),
)

Expand Down
2 changes: 1 addition & 1 deletion service/history/ndc/history_replicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ func (r *HistoryReplicatorImpl) ApplyWorkflowState(
return err
}

taskRefresh := workflow.NewTaskRefresher(r.shard, r.shard.GetConfig(), r.namespaceRegistry, r.shard.GetEventsCache(), r.logger)
taskRefresh := workflow.NewTaskRefresher(r.shard, r.shard.GetConfig(), r.namespaceRegistry, r.logger)
err = taskRefresh.RefreshTasks(ctx, mutableState)
if err != nil {
return err
Expand Down
1 change: 0 additions & 1 deletion service/history/ndc/state_rebuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ func NewStateRebuilder(
shard,
shard.GetConfig(),
shard.GetNamespaceRegistry(),
shard.GetEventsCache(),
logger,
),
rebuiltHistorySize: 0,
Expand Down
86 changes: 5 additions & 81 deletions service/history/workflow/task_refresher.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
"go.temporal.io/server/common/namespace"
"go.temporal.io/server/common/primitives/timestamp"
"go.temporal.io/server/service/history/configs"
"go.temporal.io/server/service/history/events"
"go.temporal.io/server/service/history/shard"
)

Expand All @@ -51,7 +50,6 @@ type (
shard shard.Context
config *configs.Config
namespaceRegistry namespace.Registry
eventsCache events.Cache
logger log.Logger
}
)
Expand All @@ -60,15 +58,13 @@ func NewTaskRefresher(
shard shard.Context,
config *configs.Config,
namespaceRegistry namespace.Registry,
eventsCache events.Cache,
logger log.Logger,
) *TaskRefresherImpl {

return &TaskRefresherImpl{
shard: shard,
config: config,
namespaceRegistry: namespaceRegistry,
eventsCache: eventsCache,
logger: logger,
}
}
Expand Down Expand Up @@ -269,15 +265,8 @@ func (r *TaskRefresherImpl) refreshTasksForActivity(
taskGenerator TaskGenerator,
) error {

executionInfo := mutableState.GetExecutionInfo()
executionState := mutableState.GetExecutionState()
pendingActivityInfos := mutableState.GetPendingActivityInfos()

currentBranchToken, err := mutableState.GetCurrentBranchToken()
if err != nil {
return err
}

Loop:
for _, activityInfo := range pendingActivityInfos {
// clear all activity timer task mask for later activity timer task re-generation
Expand All @@ -294,18 +283,7 @@ Loop:
continue Loop
}

scheduleEvent, err := r.eventsCache.GetEvent(
ctx,
events.EventKey{
NamespaceID: namespace.ID(executionInfo.NamespaceId),
WorkflowID: executionInfo.WorkflowId,
RunID: executionState.RunId,
EventID: activityInfo.ScheduledEventId,
Version: activityInfo.Version,
},
activityInfo.ScheduledEventBatchId,
currentBranchToken,
)
scheduleEvent, err := mutableState.GetActivityScheduledEvent(ctx, activityInfo.ScheduledEventId)
if err != nil {
return err
}
Expand Down Expand Up @@ -359,33 +337,14 @@ func (r *TaskRefresherImpl) refreshTasksForChildWorkflow(
taskGenerator TaskGenerator,
) error {

executionInfo := mutableState.GetExecutionInfo()
executionState := mutableState.GetExecutionState()
pendingChildWorkflowInfos := mutableState.GetPendingChildExecutionInfos()

currentBranchToken, err := mutableState.GetCurrentBranchToken()
if err != nil {
return err
}

Loop:
for _, childWorkflowInfo := range pendingChildWorkflowInfos {
if childWorkflowInfo.StartedEventId != common.EmptyEventID {
continue Loop
}

scheduleEvent, err := r.eventsCache.GetEvent(
ctx,
events.EventKey{
NamespaceID: namespace.ID(executionInfo.NamespaceId),
WorkflowID: executionInfo.WorkflowId,
RunID: executionState.RunId,
EventID: childWorkflowInfo.InitiatedEventId,
Version: childWorkflowInfo.Version,
},
childWorkflowInfo.InitiatedEventBatchId,
currentBranchToken,
)
scheduleEvent, err := mutableState.GetChildExecutionInitiatedEvent(ctx, childWorkflowInfo.InitiatedEventId)
if err != nil {
return err
}
Expand All @@ -406,28 +365,10 @@ func (r *TaskRefresherImpl) refreshTasksForRequestCancelExternalWorkflow(
taskGenerator TaskGenerator,
) error {

executionInfo := mutableState.GetExecutionInfo()
executionState := mutableState.GetExecutionState()
pendingRequestCancelInfos := mutableState.GetPendingRequestCancelExternalInfos()

currentBranchToken, err := mutableState.GetCurrentBranchToken()
if err != nil {
return err
}

for _, requestCancelInfo := range pendingRequestCancelInfos {
initiateEvent, err := r.eventsCache.GetEvent(
ctx,
events.EventKey{
NamespaceID: namespace.ID(executionInfo.NamespaceId),
WorkflowID: executionInfo.WorkflowId,
RunID: executionState.RunId,
EventID: requestCancelInfo.GetInitiatedEventId(),
Version: requestCancelInfo.GetVersion(),
},
requestCancelInfo.GetInitiatedEventBatchId(),
currentBranchToken,
)
initiateEvent, err := mutableState.GetRequesteCancelExternalInitiatedEvent(ctx, requestCancelInfo.GetInitiatedEventId())
if err != nil {
return err
}
Expand All @@ -448,28 +389,11 @@ func (r *TaskRefresherImpl) refreshTasksForSignalExternalWorkflow(
taskGenerator TaskGenerator,
) error {

executionInfo := mutableState.GetExecutionInfo()
executionState := mutableState.GetExecutionState()
pendingSignalInfos := mutableState.GetPendingSignalExternalInfos()

currentBranchToken, err := mutableState.GetCurrentBranchToken()
if err != nil {
return err
}

for _, signalInfo := range pendingSignalInfos {
initiateEvent, err := r.eventsCache.GetEvent(
ctx,
events.EventKey{
NamespaceID: namespace.ID(executionInfo.NamespaceId),
WorkflowID: executionInfo.WorkflowId,
RunID: executionState.RunId,
EventID: signalInfo.GetInitiatedEventId(),
Version: signalInfo.GetVersion(),
},
signalInfo.GetInitiatedEventBatchId(),
currentBranchToken,
)

initiateEvent, err := mutableState.GetSignalExternalInitiatedEvent(ctx, signalInfo.GetInitiatedEventId())
if err != nil {
return err
}
Expand Down