Skip to content

Commit

Permalink
Fix bug not setting CanSkipVisibilityArchival (#3721)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSnowden committed Dec 17, 2022
1 parent 70b5969 commit edd3f0a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
16 changes: 10 additions & 6 deletions service/history/workflow/task_generator.go
Expand Up @@ -159,13 +159,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 +206,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
5 changes: 5 additions & 0 deletions service/history/workflow/task_generator_test.go
Expand Up @@ -242,6 +242,11 @@ func TestTaskGeneratorImpl_GenerateWorkflowCloseTasks(t *testing.T) {
}
require.NotNil(t, closeExecutionTask)
assert.Equal(t, p.DeleteAfterClose, closeExecutionTask.DeleteAfterClose)
assert.Equal(
t,
p.DurableArchivalEnabled && !p.DeleteAfterClose,
closeExecutionTask.CanSkipVisibilityArchival,
)

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

0 comments on commit edd3f0a

Please sign in to comment.