-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Make rrule fast forwarding stable #15601
base: devel
Are you sure you want to change the base?
Conversation
aef1c4a
to
4057916
Compare
f2584db
to
ea714de
Compare
fd620a3
to
6f169cc
Compare
Can this be an HTTP 400 when a Schedule is created with an "invalid" rrule? Basically preventing this type of rrules to be created in the first place. Also, I would specify the value of the |
Ok, I think I understood what's going on:
Did I get that right? |
logger.warning(e) | ||
# fallback to setting dtstart to 7 days ago, but this has the consequence of | ||
# occurrences not matching the old occurrences. | ||
new_start = now() - datetime.timedelta(days=7) |
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.
as @PabloHiro mentioned, this would lead to the exact problem that is being fixed. Can we just reject the rrule 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.
I wonder how we should handle the cases where a user has these "invalid" rules already. We can prevent further invalid rules, but this code has a solution to handle the existing ones.
By stable, we mean future occurrences of the rrule should be the same before and after the fast forward operation. The problem before was that we were fast forwarding to 7 days ago. For some rrules, this does not retain the old occurrences. Thus, jobs would launch at unexpected times. This change makes sure we fast forward in increments of the rrule INTERVAL (converted to seconds), thus the new dtstart should be in the occurrence list of the old rrule. Signed-off-by: Seth Foster <[email protected]>
6f169cc
to
d2e1cfa
Compare
Quality Gate passedIssues Measures |
SUMMARY
By stable, we mean future occurrences of the rrule should be the same before and after the fast forward operation.
The problem before was that we were fast forwarding to exactly 7 days ago. For some rrules, this does not retain the old occurrences (for example, freq=HOURLY and INTERVAL=23). Thus, jobs would launch at unexpected times any time the schedule would fast forward.
This change makes sure we fast forward in increments of the rrule INTERVAL (converted to seconds), thus the new dtstart should be in the occurrence list of the old rrule.
DETAIL
Fast forward won't work for really large intervals. For example if you specify HOURLY and INTERVAL=1200 (that is 50 days worth of time), then we can't fast forward because one CHUNK of the interval doesn't fit in the period of time we are trying to fast forward (window is 30 days). In this case, we'll revert back to the old style of just updating dtstart to 7 days ago. We log a warning, so hopefully the user will update their rrule to be frequency DAYS instead of HOURS.
example log:
PERFORMANCE
This change doesn't seem to hurt performance much. Since our fast forward window is larger (30 days vs 7), there will be more rrule objects generated, so we do expect it to cost more time. I attempted to capture it empirically.
create a bunch of old schedules
runit will update_computed_fields for each schedule
benchmark it
before:
after:
So yeah, a slight slowdown, but I think it is worth it for the more accurate generation of occurrences.
ISSUE TYPE
COMPONENT NAME