-
Notifications
You must be signed in to change notification settings - Fork 876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle system time move backward case in timer task processing #7030
base: main
Are you sure you want to change the base?
Conversation
fb5f5fd
to
c3f87c1
Compare
// NOTE: Persistence layer may lose precision when persisting the task, which essentially moves | ||
// task fire time backward. But we are already performing truncation here, so doesn't need to | ||
// account for that. | ||
referenceTime = util.MaxTime(referenceTime, task.GetKey().FireTime).Truncate(persistence.ScheduledTaskMinPrecision) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the difference between visibility timestamp and fire time and why take that here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are the same for Scheduled tasks. For immediate tasks, fire time is always 0. Since this function is only meant to be invoked by scheduled tasks, I think FireTime is better as it won't have any impact on immediate tasks.
@@ -236,7 +240,7 @@ func (t *timerQueueStandbyTaskExecutor) executeActivityTimeoutTask( | |||
// created. | |||
isHeartBeatTask := timerTask.TimeoutType == enumspb.TIMEOUT_TYPE_HEARTBEAT | |||
ai, heartbeatTimeoutVis, ok := mutableState.GetActivityInfoWithTimerHeartbeat(timerTask.EventID) | |||
if isHeartBeatTask && ok && queues.IsTimeExpired(timerTask.GetVisibilityTime(), heartbeatTimeoutVis) { | |||
if isHeartBeatTask && ok && queues.IsTimeExpired(timerTask, timerTask.GetVisibilityTime(), heartbeatTimeoutVis) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we use referenceTime
to allow progressing beyond the visibility timestamp in case task processing is delayed for a while?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal here I believe is to clear the heartbeat timer task status only when we have to. Using referenceTime means we will clear the flag more often and causing more heartbeat timer task being created.
What changed?
Why?
How did you test it?
Potential risks
Documentation
Is hotfix candidate?