Skip to content
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

[Scheduler] Fix remaining count for triggers expired on creation #29

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions cronback-services/src/scheduler/spinner/active_triggers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,13 @@ pub(crate) struct ActiveTrigger {

impl ActiveTrigger {
fn try_from(
trigger: Trigger,
mut trigger: Trigger,
fast_forward: bool,
) -> Result<Self, TriggerError> {
// Do we have a cron pattern or a set of time points?
let k = trigger
.schedule
.as_ref()
.as_mut()
.ok_or_else(|| TriggerError::NotScheduled(trigger.id.clone()))?;
// On fast forward, we ignore the last run time.
let last_ran_at = if fast_forward {
Expand All @@ -360,6 +360,12 @@ impl ActiveTrigger {
trigger.last_ran_at
};
let ticks = ScheduleIter::from_schedule(k, last_ran_at)?;

// RunAt triggers in particular might have expired timepoints that will
// be skipped. Update the underlying trigger so that the
// "remaining" attribute correctly reflects that.
k.set_remaining(ticks.remaining());

// We assume that Trigger.schedule is never None
Ok(Self {
inner: trigger,
Expand Down