8

So have an ETL job that runs through integration services that I start with a SQL job name StartStageStore. The last step of this job is to start another job and report success. The job this calls to is referred to as LoopStageStore. All LoopStageStore does is execute a stored procedure that Restarts the StartStageStore job all over again this way we are constantly pulling source data into our system. This job has been running for sever weeks now without failure. Until the last two nights I started getting this error "Executed as user: AgentUser. SQLServerAgent Error: Request to run job Stage/Store AgentUser refused because the job is already running from a request by User AgentUser. [SQLSTATE 42000] (Error 22022). The step failed."

This should not be possible as the run StartStageStore job finishes and is no longer running when LoopStageStore has started.

StageStoreJob

Here we can see the last step executed at 12:19:14.LoopStageStore

And the Next Job Fails at 12:19:15 Saying that StartStageStore is currently running. I already have a workaround for this where I just throw a Delay on the Second job. I'm just wondering if anyone knows why this would happen.

BEGIN
WAITFOR DELAY '00:01';
    EXECUTE dbo.LoopStageStore
END; GO
4
  • Is sysjobhistory large? It's possible that the first job takes a significant amount of time to update the job history. Commented Oct 23, 2012 at 15:02
  • It is not. We only keep a weeks worth of job log history. However that is my assumption as to what is happening. The part that confuses me is this issue only pops up once a day at the most. The job runs a solid 20 + times a day.
    – Zane
    Commented Oct 23, 2012 at 16:07
  • The problem appears to be that one certain occasions it takes longer that 1 second to finish up that write log to the Jobs Finished Table (Starcraft Reference I know that's not the actual name). So the wait time I have placed on there should fix the problem.
    – Zane
    Commented Oct 23, 2012 at 16:17
  • I had the same error but another background and my answer did not seem to fit here. Therefore, I made it a new question at How do I avoid error "Request to run job refused because the job is already running" if no job is shown as "running" when I start a chosen step?. Commented Aug 6 at 12:48

1 Answer 1

4

Alright so the problem I was having was that the write time to the log file for job completion occasionally takes longer than it takes to run the stored procedure that restarts this loop.

The solution to this is my original workaround.

In case anyone wants to use it here is the code.

BEGIN
WAITFOR DELAY '00:01';
    EXECUTE dbo.LoopStageStore
END; GO

Just make it wait a little bit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.