citusdata / pg_cron

Run periodic jobs in PostgreSQL
PostgreSQL License
2.84k stars 192 forks source link

cron jobs do nor work at scheduled time and can not create a new job #249

Open ismailyurek-eva opened 1 year ago

ismailyurek-eva commented 1 year ago

Hi,

We were using PostgreSQL 13.7, and the "cron jobs" stopped suddenly after the database shut down and didn't restart again at the scheduled time. We have upgraded the database from 13.7 to 13.10. After upgrading (also db restarted), the jobs started again.

But, we faced another issue while creating a new job with job-name parameter.

Execution 1: Job could not be created.

SELECT cron.schedule('vacuum_my_db_table', '0 04 *', 'VACUUM ANALYZE my_db_table') This execution throws the following error: "ERROR: invalid memory alloc request size [N]"

Execution 2: Db could not be reachable.

SELECT cron.schedule('xxxx', '0 04 *', 'VACUUM ANALYZE my_db_table') This execution throws the following error: "FATAL: the database system is in recovery mode"

After this error, the is not accessible, but AWS RDS monitoring says "it is available." It looks like the function considers the "name parameter" as scheduled time.

Execution 3: It worked, and the job was created.

SELECT cron.schedule('0 04 *', 'VACUUM ANALYZE my_db_table')

In summary, the cron.schedule function can not be executed with three parameters (named job), and causes db to be unreachable.

chad-phrase commented 1 year ago

Had a similar issue (using v13.8) and was getting ERROR: invalid memory alloc request size .... Possibly from creating "too many" cron jobs? In any case, the solution was the same, just don't pass in the first argument.

marcocitus commented 1 year ago

which pg_cron version is used?