Skip to content

Commit 476c9bb

Browse files
samarabbaswxing1292
authored andcommitted
Prevent duplicate user timer creation (#832)
TimerQueueProcesor logic is not setting the correct value on timer information on mutable state to detect if the timer is already created or not. This fix creates the value to TimerTaskStatusCreated to prevent creation of same user timer again.
1 parent 8f6952d commit 476c9bb

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

service/history/timerBuilder.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func (tb *timerBuilder) GetUserTimerTaskIfNeeded(msBuilder *mutableStateBuilder)
202202
if timerTask != nil {
203203
// Update the task ID tracking if it has created timer task or not.
204204
ti := tb.pendingUserTimers[tb.userTimers[0].TimerID]
205-
ti.TaskID = 1
205+
ti.TaskID = TimerTaskStatusCreated
206206
// TODO: We append updates to timer tasks twice. Why?
207207
msBuilder.UpdateUserTimer(ti.TimerID, ti)
208208
}
@@ -372,16 +372,6 @@ func (tb *timerBuilder) createActivityTimeoutTask(fireTimeOut int32, timeoutType
372372
}
373373
}
374374

375-
func (tb *timerBuilder) loadUserTimer(expires time.Time, timerID string, taskCreated bool) (*timerDetails, bool) {
376-
seqNum := tb.localSeqNumGen.NextSeq()
377-
timer := &timerDetails{
378-
TimerSequenceID: TimerSequenceID{VisibilityTimestamp: expires, TaskID: seqNum},
379-
TimerID: timerID,
380-
TaskCreated: taskCreated}
381-
isFirst := tb.insertTimer(timer)
382-
return timer, isFirst
383-
}
384-
385375
func (tb *timerBuilder) insertTimer(td *timerDetails) bool {
386376
size := len(tb.userTimers)
387377
i := sort.Search(size,

service/history/timerQueueActiveProcessor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ Update_History_Loop:
259259
timerTasks = []persistence.Task{nextTask}
260260

261261
// Update the task ID tracking the corresponding timer task.
262-
ti.TaskID = nextTask.GetTaskID()
262+
ti.TaskID = TimerTaskStatusCreated
263263
msBuilder.UpdateUserTimer(ti.TimerID, ti)
264264
defer t.notifyNewTimers(timerTasks)
265265
}

0 commit comments

Comments
 (0)