January 12, 2023 at 7:02 pm
Hello experts,
I'm hoping to get help with a strange issue. I got a request to stop a long-running SQL Agent job. The client correctly sees that the job history says the job is running.
But when I checked the Job Activity Monitor, it says the job is idle and last succeeded at such-and-such a time. I have attached screenshots to illustrate the difference.
Furthermore, I found some T-SQL code to stop a job and it returns this error:
Msg 22022, Level 16, State 1, Line 0
SQLServerAgent Error: Request to stop job [] (from User []) refused because the job is not currently running.
Does anyone know what is happening here and how to fix it?
Specifically, will the job start again at its scheduled time, or will that fail? That is the client's main concern.
Thanks for any help.
-- webrunner
-------------------
A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
January 12, 2023 at 7:53 pm
What do you mean "the job history says the job is running." The jobhistory never shows that, it only show the past history.
Be sure to verify the instance_id. If it's not the current instance_id, then the job's almost certainly not currently running, no matter what the history shows.
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
January 12, 2023 at 8:00 pm
Does the client need to hit refresh? I have been fooled many times.
January 12, 2023 at 8:21 pm
What do you mean "the job history says the job is running." The jobhistory never shows that, it only show the past history.
Be sure to verify the instance_id. If it's not the current instance_id, then the job's almost certainly not currently running, no matter what the history shows.
Thanks, Scott. I mean in the first screen shot below, the Message says "In progress."
-- webrunner
-------------------
A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
January 12, 2023 at 8:22 pm
Thanks Ed,
I tried Refresh, and I even restarted SQL Server Agent. Still the same discrepancy.
-- webrunner
-------------------
A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
January 12, 2023 at 8:36 pm
ScottPletcher wrote:What do you mean "the job history says the job is running." The jobhistory never shows that, it only show the past history.
Be sure to verify the instance_id. If it's not the current instance_id, then the job's almost certainly not currently running, no matter what the history shows.
Thanks, Scott. I mean in the first screen shot below, the Message says "In progress."
-- webrunner
What "message"? Again, no msg like that appears in job history. What/where is that msg from? If the job activity monitor says the job is idle, it's idle.
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
January 12, 2023 at 8:37 pm
Again, are you only looking at history for the current instance_id value?
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
January 12, 2023 at 8:47 pm
Hi Scott,
This is what I see:
-- webrunner
-------------------
A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
January 12, 2023 at 8:56 pm
What does the job activity monitor say? If it shows a status of idle I would delete the job history and check it again tomorrow.
If the job is not running and you want to clean history you could add a step at the end of the job that does nothing. Then start the job at the final step. This will test whether the job can be started, and it should result in success. You can then delete the last step and check history.
January 12, 2023 at 9:01 pm
Hi Ed,
The Job Activity Monitor says idle / succeeded.
I'll try your suggestions. Thanks!
-- webrunner
-------------------
A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
January 18, 2023 at 7:08 pm
A typical cause of this is the server or SQL agent being restarted while the job was running. The next time the job runs it will add to the history of the one that appears to be running then mark it as finished when that iteration completes.
January 18, 2023 at 7:19 pm
Thanks again, all.
I actually ended up doing nothing, and the next day the job history showed that the job succeeded at that scheduled time. And the previous, "In progress," entry (for 1/11/2023) was just gone. Weird.
I do appreciate your replies, though. They will definitely help me troubleshoot if this happens again, and maybe I can figure out what happened to that particular job run and its history.
-- webrunner
-------------------
A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply