Skip to content

Commit

Permalink
Fix bug not setting CanSkipVisibilityArchival
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSnowden committed Dec 16, 2022
1 parent 0b4df6a commit 454b1d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
17 changes: 11 additions & 6 deletions service/history/workflow/task_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"go.temporal.io/api/serviceerror"

enumsspb "go.temporal.io/server/api/enums/v1"

"go.temporal.io/server/common/backoff"
"go.temporal.io/server/common/namespace"
"go.temporal.io/server/common/persistence/versionhistory"
Expand Down Expand Up @@ -159,13 +160,14 @@ func (r *TaskGeneratorImpl) GenerateWorkflowCloseTasks(

currentVersion := r.mutableState.GetCurrentVersion()

closeExecutionTask := &tasks.CloseExecutionTask{
// TaskID, Visiblitytimestamp is set by shard
WorkflowKey: r.mutableState.GetWorkflowKey(),
Version: currentVersion,
DeleteAfterClose: deleteAfterClose,
}
closeTasks := []tasks.Task{
&tasks.CloseExecutionTask{
// TaskID, Visiblitytimestamp is set by shard
WorkflowKey: r.mutableState.GetWorkflowKey(),
Version: currentVersion,
DeleteAfterClose: deleteAfterClose,
},
closeExecutionTask,
}

// To avoid race condition between visibility close and delete tasks, visibility close task is not created here.
Expand Down Expand Up @@ -205,6 +207,9 @@ func (r *TaskGeneratorImpl) GenerateWorkflowCloseTasks(
// archiveTime is the time when the archival queue recognizes the ArchiveExecutionTask as ready-to-process
archiveTime := closeEvent.GetEventTime().Add(delay)

// We can skip visibility archival in the close execution task if we are using the durable archival flow.
// The visibility archival will be handled by the archival queue.
closeExecutionTask.CanSkipVisibilityArchival = true
task := &tasks.ArchiveExecutionTask{
// TaskID is set by the shard
WorkflowKey: r.mutableState.GetWorkflowKey(),
Expand Down
1 change: 1 addition & 0 deletions service/history/workflow/task_generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ func TestTaskGeneratorImpl_GenerateWorkflowCloseTasks(t *testing.T) {
}
require.NotNil(t, closeExecutionTask)
assert.Equal(t, p.DeleteAfterClose, closeExecutionTask.DeleteAfterClose)
assert.Equal(t, p.DurableArchivalEnabled, closeExecutionTask.CanSkipVisibilityArchival)

if p.ExpectCloseExecutionVisibilityTask {
assert.NotNil(t, closeExecutionVisibilityTask)
Expand Down

0 comments on commit 454b1d4

Please sign in to comment.