citusdata / citusdata/pg_cron

Leap year scheduling problem

Open
#329 16 comments 5 reactions 0 assignees View on GitHub
Dominant language
C
Stars
3.9k
Forks
260
Avg merge
5d 5h
Merged PRs (30d)
1

Description

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:
```html
jobid | schedule | command | nodename | nodeport | database | username | active | jobname
-- | -- | -- | -- | -- | -- | -- | -- | --
22 | 40 07 * * 4 | SELECT 1 | localhost | 5,432 | dbname | username | true | WandaVisionToday
21 | 40 07 * * 5 | SELECT 1 | localhost | 5,432 | dbname | username | true | WandaVision
```

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:`

```html
jobid | runid | job_pid | database | username | command | status | return_message | start_time | end_time
-- | -- | -- | -- | -- | -- | -- | -- | -- | --
21 | 7 | 43,042 | dbname| username| SELECT 1 | succeeded | SELECT 1 | 2024-05-16 09:40:00.034 +0200 | 2024-05-16 09:40:01.050 +0200
```

I hope it can help solve the problem.

Best regards
Marco

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.