Re: elegant and effective way for running jobs inside a database

From: Artur Litwinowicz <admin(at)ybka(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: elegant and effective way for running jobs inside a database
Date: 2012-03-06 17:20:48
Message-ID: 4F564770.5060307@ybka.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
0xAF4A859D.asc application/pgp-keys 11.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2012-03-06 17:22:55 Re: Checksums, state of play
Previous Message Robert Haas 2012-03-06 17:14:45 Re: Checksums, state of play