Re: RFC: pgAgent Scheduler Design - Mailing list pgadmin-hackers

From Andreas Pflug
Subject Re: RFC: pgAgent Scheduler Design
Date
Msg-id 4231F1B4.2030803@pse-consulting.de
Whole thread Raw
In response to Re: RFC: pgAgent Scheduler Design  ("Dave Page" <dpage@vale-housing.co.uk>)
List pgadmin-hackers
Dave Page wrote:
>
>
>
>>-----Original Message-----
>>From: Andreas Pflug [mailto:pgadmin@pse-consulting.de]
>>Sent: 08 March 2005 18:28
>>To: Dave Page
>>Cc: pgadmin-hackers@postgresql.org
>>Subject: Re: [pgadmin-hackers] RFC: pgAgent Scheduler Design
>>
>>Dave Page wrote:
>>
>>
>>>>obs (shell jobs) need a system qualifier.
>>>>
>>>>
>>>
>>>Well that would tie in with the multi-thread model, and the
>>
>>current code
>>

>
>
> Which isn't done in the same transaction as the original select, thus
> allowing a window in which another agent might grab the same job and
> execute it (though from my reading of the code, the second instance
> won't bother to log it's start time, and will probably mess up the
> logging of step results because prtid will be an empty string). Unless
> I'm missing something of course...

You do.

int rc=serviceConn->ExecuteVoid(
      "UPDATE ... SET jobagentpid=pg_backend_pid() ...
          WHERE jobagentid IS NULL ...");

if (rc == 1) // i.e. if exactly one row was affected, it's our job now.

Regards,
Andreas

pgadmin-hackers by date:

Previous
From: cvs@developer.pgadmin.org
Date:
Subject: CVS Commit by dpage: Number weekdays correctly.
Next
From: "Dave Page"
Date:
Subject: Re: RFC: pgAgent Scheduler Design