How to remove "failed" status for job that is automatically restarted?

  • I have set up a small system with merge replication; on the subscribers there is an anonymous pull subscription where the merge agaent is running continuously (needed for low latency).

    From time to time the merge agent stops running due to an error (such as a deadlock, or the Publisher is off-line). To guard against this I have created a "watchdog" job that runs periodically, checks the status of the merge agent and if it is found not to be running restarts it.

    However, if subsequently I go in and look at the jobs using the Enterprise Manager (Management | SQL Server Agent | Jobs), after a failure the merge agent's job is shown with a "failed" (red 'X') icon - even though it was restarted successfully and while I am looking at it with the Enterprise Manager the merge agent's job is executing normally.

    Purging the job history using the Enterprise Manager or the system stored procedure sp_purge_jobhistory, then refreshing the job display doesn't clear this "erroneous" failed indication; the only sure-fire way I have found to clear it is to manually stop the merge agent job, restart it and refresh the job display in the Enterprise Manager.

    The Enterprise Manager is stubbornly holding on to the knowledge that the "last run outcome" was "failed" - even though the job was successfully restarted and is still running. Are there any tables entries I can clear out, system stored procedures I can run to purge this (IMO stale) knowledge so that when refreshed the Enterprise Manager will not show the red 'X' against the job.

    BTW - I spotted that the "last run outcome" appears to be held in the msdb database - sysjobsteps table - however simply overwriting the "failed" value (0) in the last_run_outcome column with a "success" value (1) or "cancelled" value (3) doesn't fool the Enterprise Manager 🙁

    Thanks,

    Richard Culpan

  • Enterprise Manager displays the status of the last completed run. In your case, that was a failure.

    What you asked for is the have EM behave differently than it was designed. I suggest you just put up with it and move on.



    Alvin Ramard
    Memphis PASS Chapter[/url]

    All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.

    For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]

  • Thanks for the reply - at least I know someone is reading the message 🙂 I had kinda discovered that Enterprise Manager worked that way - but I keep getting asked by the technicians that help me administer the system "I see a red cross on the merge agent job - is it all right?"

    I was hoping that someone might know a trick for fooling EM into thinking everything was fine with the merge agent job unless it stopped completely and couldn't be restarted by my "watchdog" job.

    Regards,

    Richard

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply