Skip to content

Update redispatcher to respect task redispatch time #6639

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

Merged
merged 1 commit into from
Jan 23, 2025

Conversation

Shaddoll
Copy link
Member

What changed?

  • Update redispatcher to use timer gate instead of timer
  • Set the timer gate to fire at the earliest redispatch time of all tasks
  • Deprecate TaskRedispatchIntervalJitterCoefficient dynamicconfig

Why?
Redispatcher previously was triggered periodically in the background and send all the tasks that should be redispatched before now to the task scheduler. This creates 2 issues:

  • When there is no task to be redispatched, it's still waken up by the timer
  • When there are tasks to be redispatched, it might be waken up by the timer too late, in which case the redispatch time of the task is not respected.

How did you test it?
unit tests

Potential risks
Redispatcher not working

Release notes

Documentation Changes

@@ -261,44 +253,21 @@ func (r *redispatcherImpl) redispatchTasks(notification redispatchNotification)
totalRedispatched++
}
}
if !pq.IsEmpty() {
item, _ := pq.Peek()
r.timerGate.Update(item.redispatchTime)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if Peek() returned error. item might be nil

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peek never returns error if it's not empty.
Maybe I can introduce a new method MustPeek, which is only used on non-empty queue

@Shaddoll Shaddoll merged commit 61caf40 into cadence-workflow:master Jan 23, 2025
21 of 22 checks passed
@Shaddoll Shaddoll deleted the redispatcher branch January 23, 2025 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants