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