Skip to content

Commit edd3f0a

Browse files
Fix bug not setting CanSkipVisibilityArchival (#3721)
1 parent 70b5969 commit edd3f0a

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

service/history/workflow/task_generator.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,14 @@ func (r *TaskGeneratorImpl) GenerateWorkflowCloseTasks(
159159

160160
currentVersion := r.mutableState.GetCurrentVersion()
161161

162+
closeExecutionTask := &tasks.CloseExecutionTask{
163+
// TaskID, Visiblitytimestamp is set by shard
164+
WorkflowKey: r.mutableState.GetWorkflowKey(),
165+
Version: currentVersion,
166+
DeleteAfterClose: deleteAfterClose,
167+
}
162168
closeTasks := []tasks.Task{
163-
&tasks.CloseExecutionTask{
164-
// TaskID, Visiblitytimestamp is set by shard
165-
WorkflowKey: r.mutableState.GetWorkflowKey(),
166-
Version: currentVersion,
167-
DeleteAfterClose: deleteAfterClose,
168-
},
169+
closeExecutionTask,
169170
}
170171

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

209+
// We can skip visibility archival in the close execution task if we are using the durable archival flow.
210+
// The visibility archival will be handled by the archival queue.
211+
closeExecutionTask.CanSkipVisibilityArchival = true
208212
task := &tasks.ArchiveExecutionTask{
209213
// TaskID is set by the shard
210214
WorkflowKey: r.mutableState.GetWorkflowKey(),

service/history/workflow/task_generator_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@ func TestTaskGeneratorImpl_GenerateWorkflowCloseTasks(t *testing.T) {
242242
}
243243
require.NotNil(t, closeExecutionTask)
244244
assert.Equal(t, p.DeleteAfterClose, closeExecutionTask.DeleteAfterClose)
245+
assert.Equal(
246+
t,
247+
p.DurableArchivalEnabled && !p.DeleteAfterClose,
248+
closeExecutionTask.CanSkipVisibilityArchival,
249+
)
245250

246251
if p.ExpectCloseExecutionVisibilityTask {
247252
assert.NotNil(t, closeExecutionVisibilityTask)

0 commit comments

Comments
 (0)