pg_cron hangs when cron.max_running_jobs is exceeded
- Dominant language
- C
- Stars
- 3.9k
- Forks
- 260
- Avg merge
- 5d 5h
- Merged PRs (30d)
- 1
Description
There is a bug in the state machine that causes pg_cron to indefinitely wait for jobs that it thinks are running, but are actually idle.
I can't tell exactly where the bug is, but it happens when `max_running_jobs` is exceeded.
Here is a way to reproduce it:
- Set `cron.max_running_jobs = 1` in `postgresql.conf` and start PostgreSQL.
- Define two jobs:
SELECT cron.schedule('* * * * *', 'SELECT pg_sleep(30)');
SELECT cron.schedule('* * * * *', 'SELECT pg_sleep(30)');
First one of the jobs is started.
When that one is done, the other one is started.
The second job never finishes, although the connection has become idle.
We end up with `max_running_jobs` idle connections that completely block `pg_cron`.
Attaching to the `pg_cron` with gdb shows an endless repetition of
poll([{fd=-1}], 1, 1000) = 0 (Timeout)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.