Skip to content

Commit

Permalink
Prevent duplicate user timer creation (#832)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
samarabbas authored and wxing1292 committed Jun 9, 2018
1 parent 8f6952d commit 476c9bb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
12 changes: 1 addition & 11 deletions service/history/timerBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func (tb *timerBuilder) GetUserTimerTaskIfNeeded(msBuilder *mutableStateBuilder)
if timerTask != nil {
// Update the task ID tracking if it has created timer task or not.
ti := tb.pendingUserTimers[tb.userTimers[0].TimerID]
ti.TaskID = 1
ti.TaskID = TimerTaskStatusCreated
// TODO: We append updates to timer tasks twice. Why?
msBuilder.UpdateUserTimer(ti.TimerID, ti)
}
Expand Down Expand Up @@ -372,16 +372,6 @@ func (tb *timerBuilder) createActivityTimeoutTask(fireTimeOut int32, timeoutType
}
}

func (tb *timerBuilder) loadUserTimer(expires time.Time, timerID string, taskCreated bool) (*timerDetails, bool) {
seqNum := tb.localSeqNumGen.NextSeq()
timer := &timerDetails{
TimerSequenceID: TimerSequenceID{VisibilityTimestamp: expires, TaskID: seqNum},
TimerID: timerID,
TaskCreated: taskCreated}
isFirst := tb.insertTimer(timer)
return timer, isFirst
}

func (tb *timerBuilder) insertTimer(td *timerDetails) bool {
size := len(tb.userTimers)
i := sort.Search(size,
Expand Down
2 changes: 1 addition & 1 deletion service/history/timerQueueActiveProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ Update_History_Loop:
timerTasks = []persistence.Task{nextTask}

// Update the task ID tracking the corresponding timer task.
ti.TaskID = nextTask.GetTaskID()
ti.TaskID = TimerTaskStatusCreated
msBuilder.UpdateUserTimer(ti.TimerID, ti)
defer t.notifyNewTimers(timerTasks)
}
Expand Down

0 comments on commit 476c9bb

Please sign in to comment.