Skip to content

Commit 8e1d294

Browse files
committed
initial draft
1 parent 727116f commit 8e1d294

1 file changed

Lines changed: 74 additions & 2 deletions

File tree

support/sql/database-engine/agent/job-failed-error-258.md

Lines changed: 74 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Troubleshoot SQL Agent Job Failures with Error 258
3-
description: Learn how to troubleshoot and resolve repeated crashes of the SQL Agent service. Follow step-by-step solutions to fix registry issues and improve stability.
3+
description: Troubleshoot SQL Agent job failures with error 258. Learn how to resolve timeout issues, fix registry problems, and ensure stable job execution.
44
ms.date: 12/04/2025
55
ms.custom: sap:SQL Agent (Jobs, Alerts, Operators)\Job failures, job scheduling and monitoring
66
ms.reviewer: prmadhes, v-shaywood
@@ -27,11 +27,83 @@ Logon to server '<ServerName>' failed (ConnLogJobHistory)
2727

2828
This issue can be caused by any of the following underlying problems:
2929

30-
- Blocking of `msdb` system tables used by Agent, which prevents job metadata reads and writes.
30+
- Blocking on `msdb` system tables used by Agent, which prevents job metadata reads and writes.
3131
- Example system tables: `dbo.sysjobs`, `dbo.sysjobschedulers`, and `dbo.jobsteps`.
3232
- Hangs inside important SQL Server Agent threads or other process-level problems.
3333
- Worker thread exhaustion in SQL Server (no workers available), making the Agent unable to connect or process schedules.
3434

3535
## Solution
3636

37+
1. Confirm that the SQL Server Agent service is running by using the following PowerShell command:
3738

39+
```powershell
40+
Get-Service -Name "SQLSERVERAGENT"
41+
```
42+
43+
1. If the SQL Server Agent service is not already running, start it.
44+
1. Check the jobs and schedules in `msdb` by opening [SQL Server Management Studio (SSMS)](/ssms/install/install) and running the following query: <!-- Check with SME, what the user should do with the output of this query -->
45+
46+
```tsql
47+
USE msdb;
48+
GO
49+
50+
-- List enabled jobs
51+
SELECT name, enabled, description FROM msdb.dbo.sysjobs WHERE enabled = 1;
52+
GO
53+
54+
-- Show job schedules and next run
55+
SELECT s.name AS ScheduleName,
56+
j.name AS JobName,
57+
s.enabled AS ScheduleEnabled,
58+
s.active_start_date,
59+
s.active_end_time
60+
FROM msdb.dbo.sysjobs j
61+
JOIN msdb.dbo.sysjobschedules js ON j.job_id = js.job_id
62+
JOIN msdb.dbo.sysschedules s ON js.schedule_id = s.schedule_id
63+
WHERE j.enabled = 1;
64+
GO
65+
```
66+
67+
1. Detect blocking on `msdb` Agent system tables by running the following query is SSMS:
68+
69+
```tsql
70+
USE msdb;
71+
GO
72+
73+
SELECT session_id, blocking_session_id, wait_type, wait_duration_ms, resource_description
74+
FROM sys.dm_os_waiting_tasks
75+
WHERE resource_description LIKE '%sysjobs%'
76+
OR resource_description LIKE '%sysjobschedulers%'
77+
OR resource_description LIKE '%jobsteps%';
78+
GO
79+
```
80+
81+
1. If blocking sessions are found, investigate the blocking query using `sys.dm_exec_requests` and `sys.dm_exec_sql_text`. Then, resolve or kill the blocking session.
82+
1. Check the system health extended events for any worker, thread, or resource issues by running the following query is SSMS:
83+
84+
```tsql
85+
?????
86+
```
87+
88+
Inspect the query results for `QUERY_PROCESSING`, `RESOURCE`, and `SYSTEM` components, look for thread exhaustion, memory pressure, or CPU issues.
89+
90+
<!-- Check with SME what the user should do if they identify any thread exhaustion, memory pressure, or CPU issues -->
91+
92+
1. If blocking, hangs, or worker exhaustion can't be resolved, restart SQL Server Agent by running the following commands in PowerShell:
93+
94+
```powershell
95+
Restart-Service -Name "SQLSERVERAGENT" -Force
96+
net stop "SQL Server Agent (MSSQLSERVER)"
97+
net start "SQL Server Agent (MSSQLSERVER)"
98+
```
99+
100+
> [!IMPORTANT]
101+
> Restarting the SQL Server Agent will interrupt any currently running jobs.
102+
103+
After the SQL Server Agent restarts, verify that jobs are now being executed by using the [Job Activity Monitor](/ssms/agent/monitor-job-activity#job-activity-monitor).
104+
105+
## Related content
106+
107+
- [SQL Server Agent overview](/ssms/agent/sql-server-agent)
108+
- [View the SQL Server Agent error log](/ssms/agent/view-sql-server-agent-error-log-sql-server-management-studio)
109+
- [Create a SQL Server Agent job](/ssms/agent/create-a-job)

0 commit comments

Comments
 (0)