-
Notifications
You must be signed in to change notification settings - Fork 203
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
Leap year scheduling problem #329
Comments
That's interesting, so far no luck in reproducing it. I tried scheduling something at 8:38am on 17/5 (today) with I also tried scheduling something at 8:41am on Friday (today) with What does SELECT now() return? |
I set the timestamp to Europe/Rome. |
I am having the same issue. I have a bunch of jobs that I scheduled on Mondays, but they are running on Sundays since March 2024 (which supports the assumption that this is caused by the leap year). This is what I get from
You can see here that the Monday jobs ran fine in February (5th, 12th , 19th and 26th are all Mondays) and they started running on Sunday since March 3rd. I am running postgres on Google Cloud using Cloud SQL, with the maintenance version SELECT NOW(); gives me the correct time: Moreover you can see in the |
I am having the same issue, and I found that pg_cron doesn't recognize leap years, and the bug inited after February 28. The same happens with weekdays, and for today (Friday), I have to schedule it for tomorrow (Saturday). Initially, the problem occurred on the PG12 cluster, but further tests shown the same error on AWS RDS pg15. |
I am also facing the same issue with the @monthly job that was running on the last day of the previous month in 2024 year.
|
Could it be related to 35d1475? |
Hello, I submitted the time zone guc parameter (but it's been a long time since today). Do you have a way to reproduce this leap year error? Looking forward to your reply, thank you |
I have faced this issue in AWS Aurora PostgreSQL and used UTC for the database timestamp and cron as below |
Hi TsinghuaLucky912 - There are no issues with the daily or hourly scheduler jobs, only with the monthly job(i.e., First of the month).You can find more details in my first post. If you schedule any jobs monthly, the issue can be reproduced. I scheduled a job to run at @monthly, and there were no issues in 2023. The job started and ended as expected. Here are the old job history information for your reference.
|
Thank you very much for your supplement. Your plan starts on the first day of each month, but starting from the second execution in 2024, the time is wrong. The correct time should be 2024-02-01. I want to know what your timezone and cron.timezone configurations are? And your cron configuration (time) rules? ps: It has been a long time since I submitted cron.timezone, and I am trying to understand the modifications made by others later😄 |
Yes, correct time should be beginning of the months similar to 2023 plan year. |
What are your cron configuration rules? |
Cron conf rule is * @monthly and 10 00 01 * * or 10 0 1 * * |
Hi everyone, I just had a chat with my friend (zhaojunwang): When the cron configuration is @monthly, we guess that the reason why the wrong time 2024-01-31 can be executed is: // ShouldRunTask
...
bool lastdom = (schedule->flags & DOM_LAST) != 0 && tomorrow_tm->tm_mday == 1; // false
bool thisdom = lastdom || bit_test(schedule->dom, dayOfMonth) != 0; // false
bool thisdow = bit_test(schedule->dow, dayOfWeek); // true
if (bit_test(schedule->minute, minute) &&
bit_test(schedule->hour, hour) &&
bit_test(schedule->month, month) &&
( (schedule->flags & (DOM_STAR|DOW_STAR)) != 0 // true
? (thisdom && thisdow) : (thisdom) || thisdow)) { // here
if ((doNonWild && !(schedule->flags & (MIN_STAR|HR_STAR)))
|| (doWild && (schedule->flags & (MIN_STAR|HR_STAR))))
{
return true;
}
}
... This line of code has a parenthesis problem (scope), which causes || thisdow to be re-applied after the ternary operator. This is not the real purpose of the patch introduced before. He resubmitted a patch, and these are my current analysis. Thank you! |
I need help with verifying if the issue is resolved by #365 that is released in v1.6.5. It will take some time before the OS packages are ready though. |
For my project we use Postgres 12 and the pg_cron extension at version 1.6.
During the testing phase we realized that the scheduling for the days of the week does not work correctly and the cause is linked to the current year which is a leap year.
Scheduling these jobs:
job 22 refers to the schedule with day of the week 5 (Friday) while the job with id 21 refers to a schedule with day of the week 4 (Thursday) or (Today 16/05/2024).
We noticed that job 21 was not executed while job 22 was executed. We expected the opposite. This made me think that one cause could be pg_cron's handling of leap years. I think it's all there.
Below is the extraction of the
cron.job_run_details:
I hope it can help solve the problem.
Best regards
Marco
The text was updated successfully, but these errors were encountered: