Обсуждение: PGAgent runs all jobs on startup

Поиск
Список
Период
Сортировка

PGAgent runs all jobs on startup

От
David Greco
Дата:
<div class="WordSection1"><p class="MsoNormal">I have about 20 jobs scheduled via PGAgent to run at various times. Some
daily,some every X minutes, some at certain times, etc. I just started pgagent on the server and noticed it ran all my
jobsupon startup, despite it not being a scheduled time. Is this an option somewhere I’m missing?<p
class="MsoNormal"> <pclass="MsoNormal"> </div> 

Re: PGAgent runs all jobs on startup

От
Dave Page
Дата:
On Mon, Aug 12, 2013 at 7:35 PM, David Greco
<David_Greco@harte-hanks.com> wrote:
> I have about 20 jobs scheduled via PGAgent to run at various times. Some
> daily, some every X minutes, some at certain times, etc. I just started
> pgagent on the server and noticed it ran all my jobs upon startup, despite
> it not being a scheduled time. Is this an option somewhere I’m missing?

No, this was an intentional design choice - we actually polled the
community to find out what behaviour people wanted here. Essentially,
when the agent restarts it plays "catchup", and runs all the jobs it
missed. It then recalculates the new runtime for each that is always
in the future. So, if you had an hourly job and the agent was down
from 11:30 until 17:30, it would run the 12:00 instance of the job at
startup (17:30) then resume the normal schedule at 18:00.

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



Re: PGAgent runs all jobs on startup

От
David Greco
Дата:
-----Original Message-----
From: Dave Page [mailto:dpage@pgadmin.org] 
Sent: Tuesday, August 13, 2013 4:13 AM
To: David Greco
Cc: PgAdmin Support (pgadmin-support@postgresql.org)
Subject: Re: [pgadmin-support] PGAgent runs all jobs on startup

On Mon, Aug 12, 2013 at 7:35 PM, David Greco <David_Greco@harte-hanks.com> wrote:
> I have about 20 jobs scheduled via PGAgent to run at various times. 
> Some daily, some every X minutes, some at certain times, etc. I just 
> started pgagent on the server and noticed it ran all my jobs upon 
> startup, despite it not being a scheduled time. Is this an option somewhere I’m missing?

No, this was an intentional design choice - we actually polled the community to find out what behaviour people wanted
here.Essentially, when the agent restarts it plays "catchup", and runs all the jobs it missed. It then recalculates the
newruntime for each that is always in the future. So, if you had an hourly job and the agent was down from 11:30 until
17:30,it would run the 12:00 instance of the job at startup (17:30) then resume the normal schedule at 18:00.
 

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com The Enterprise PostgreSQL Company




Got it thanks. I looked at the source and saw that was the case. I changed the startup script to go ahead and update
thenextrundate for all jobs to null (a trigger then takes care of setting it to the proper date). If I was polled, I
probablywould have made it a command-line switch to pgagent, or even make it configurable on a per-job basis. I have
somejobs that are critical they run at a particular time, others don't matter, maybe a couple that I would want to
catchup.