Re: elegant and effective way for running jobs inside a database - Mailing list pgsql-hackers

From Artur Litwinowicz
Subject Re: elegant and effective way for running jobs inside a database
Date
Msg-id 4F564770.5060307@ybka.com
Whole thread Raw
In response to Re: elegant and effective way for running jobs inside a database  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: elegant and effective way for running jobs inside a database  (Christopher Browne <cbbrowne@gmail.com>)
List pgsql-hackers
With all the respect to all into this Community...
I have no experience enough rich with C or C++ to say yes I can do that
alone. I do not know the internals of PostgreSQL at all. But I have
quite long experience with other languages.
I imagine if you have a piece of code which can run function like
"Select function(123);" you can reuse it (with some modifications) to
run jobs saved in job manager tables in the same manner. All we need is
two "crazy" (some simplification) loops - one for job running and one
for control and logging purposes - all fast enought with period not
slower then 5s or faster.

Algorithm for first loop:
check jobs exists and is time to run it
   run job as other sql statements (some validity check may be done)
   get next job
no jobs - delay

second loop:
find started job
   check it is still working
      if error log it, calculate next start time
        (may be longer then at the first time)
        if configured and clean up
      if works fine log duration
      if just finished log it, calculate next run and clean up
   find next job
no jobs - delay

And it will be art of state if the job could return (but not have to)
next run time value (for log loop to save).
And it is quite all about I wanted to say - do not understand me bad (I
do not want to teach anyone or something like that ;) - I wanted just
explain what I meant.

Best regards,
Artur


Attachment

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Checksums, state of play
Next
From: Simon Riggs
Date:
Subject: Re: Checksums, state of play