I am using SQL Server 2014 and I have a job (called ITB) which has been scheduled to run at 4.00am on a daily basis. The SQL job has 11 steps in it.
At 09.00 am this morning, I noticed that the job was showing 'In Progress' in the job history. It seems to be stuck at Step 8 of 11.
I have tried to stop the job by right clicking the job name in SSMS but I am getting the following message:
"Stop failed for Job 'ITB' (Microsoft.SqlServer.Smo)
I have also tried running the following T-SQL command in SSMS to stop the job:
USE msdb ;
GO
EXEC dbo.sp_stop_job
N'ITB' ;
GO
I am getting the following message is SSMS:
Msg 22022, Level 16, State 1, Line 2
SQLServerAgent Error: Request to stop job ITB (from User sa) refused because the job is not currently running.
What is happening here and how can I deal with this?
Restart SQL Server Agent
In Object Explorer, connect to the instance of the Database Engine, right-click SQL Server Agent, and then click Start, Stop, or Restart.
If the User Account Control dialog box appears, click Yes.
When prompted if you want to perform the action, click Yes.
Related
I have a database running on an azure vm with sql server. The db is in full recovery mode. The backup is configured through the web interface. Database and log backups have been working flawlessly for years. But recently the log backup was interrupted halfway through and the log backup process somehow got stuck. The following event has been logged every 5 minutes since then (reading log with managed_backup.sp_get_backup_diagnostics):
[SSMBackup2WAAdminXevent] Database Name = DB, Database ID = 777, Stage =
VerifyJobOutcome, Error Code = 0, Error Message = Warning, Additional Info = A
progress update hasn't been received from SQL Server in more than 30 minutes
for log backup. SSMBackup2WA will continue to wait.
SSMBackup2WA seem to be stuck waiting for a progress update never being received. This has resulted in no log backups being taken. The database backup have continued running without problem.
I have trouble finding the job/task used by SSMBackup2WA. I understand its not in the usual batch of SQL Server Agent jobs but somehow hidden.
My idea is to somehow cancel the existing job that is stuck in waiting loop but I have not figured out how.
I have tried to "reset" the backup process by turning off the backup and then turning it on again but that did not help.
I have no possibility to restart the sql server (and I don't know if that would help).
So since no one seemed to have an answer to this one I resorted to restarting the SQL-server. And after the restart the transaction log backup started working again!
What is interesting is the following log that appeared in the application event log during the restart. It does seem like there was a thread hanging indefinitely, waiting for an status update that never arrived. The restart seems to have taken care of it by killing this status thread and not restarting it again in the erroneous state it had ended up in.
Log Name: Application
Source: Microsoft SQL Server Automated Backup
Date: 1/15/2022 11:16:20 AM
Event ID: 57007
Task Category: None
Level: Warning
Keywords: Classic
User: N/A
Computer: wn-sqlserver1
Description:
[Warning] AutomatedBackupStatusMonitorError:
System.Exception:
Error in auto-backup status monitor thread --->
Microsoft.SqlServer.Management.IaaSAgentSqlQuery.Contract.IaaSAgentSqlQueryException:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not
found or was not accessible. Verify that the instance name
is correct and that SQL Server is configured to allow remote
connections. (provider: Named Pipes Provider, error: 40 - Could
not open a connection to SQL Server) --->
I'm using Azure DevOps SQL Server database deploy task to run a SQL Server Agent Job using its inline SQL feature which works.
However if the job fails I have some logic that generates an error from the SQL script as per below. When the script errors, that error correctly gets displayed in the task logs, however it doesn't fail the whole task but rather returns a succeeded status. This confuses the developer as they think their changes are not breaking the job when in fact they are.
Is there anyway to bubble up the error generated form the SQL script so that the SQL Server database deploy task returns a failed status instead of a succeeded status.
Please see screen shots and YAML of the release issue below:
steps:
- task: SqlDacpacDeploymentOnMachineGroup#0
displayName: 'Run SQL Agent Job'
inputs:
TaskType: sqlInline
InlineSql: |
/* SQL Agent Job Logic Here... */
/* Raise error if job fails */
RAISERROR('##vso[task.logissue type=error]]%s job has either failed or is not in a good state!', 16, 1, 'JobName') WITH LOG
DatabaseName: master
AdditionalArgumentsSql: '-QueryTimeout 1800 -IncludeSqlUserErrors -OutputSqlErrors 1 -Verbose'
Error in Azure DevOps SQL Server database deploy task not failing pipeline
You could try to use the Logging Commands to fail build from your Inline Sql scripts:
##vso[task.complete result=Failed;]DONE
##vso[task.complete]current operation
result=Succeeded|SucceededWithIssues|Failed
Finish timeline record for current task, set task result and current
operation. When result not provided, set result to succeeded. Example:
##vso[task.complete result=Succeeded;]DONE
I am using SQL Server 2016, and have some Jobs running in the SQL Server Agent. Today I found one of the job is taking too long (10hours!) to run and is still processing, so I try to stop that. I tried right-click and stop the job, it showed a success message. However, when I go to the Job Activity Monitor, it is showing that the job is still running! I also tried the following code:
USE [msdb]
GO
EXEC dbo.sp_stop_job N'Process Reserving MI (except problematic tables)'
GO
It also says the job stopped successfully. But again when I go to the Job Activity Monitor, it is showing that the job is still running!
Can any one please help?
At the end I have to ask the server team to reboot the server in order to solve this problem
I am using SQL Server 2008 to create a job to calculate some values from an external db and store to another db table. A task scheduler has been created for automating this to run daily and update results to the 2nd table. The job is getting failed with SQL message ID 3621 and severity 14. I googled this message id and got to know that it is due to insufficient privileges for the user.
By default which user will be invoking the SQL job by the task scheduler?
If you open the Task properties, you can see what account it is running as:
I'm migrating databases from SQL Server 2008 R2 to a new server running SQL Server 2012. I set up an alert for any severity >= 16. I have a maintenance plan that includes a log backup of all user databases every 5 minutes. After restoring about 10 databases to the new server, I started getting an alert every 30 minutes that says:
DESCRIPTION: BACKUP failed to complete the command BACKUP LOG MyDatabaseName. Check the backup application log for detailed messages.
COMMENT: (None)
JOB RUN: (None)
I searched the logs and there is nothing about a failed backup, and all the backups are fine. I get the alert every 30 minutes, so it's not happening on all of the log backups because they run every 5 minutes. And it's only for one or sometimes two databases out of the 10 that have been restored onto the new server.
I would greatly appreciate anyone that can point me in the right direction to start troubleshooting this.
The maintenance plan runs via a SQL Server Agent job. Check the history of the job. Any failures might show there.
Error level 16 is not considered critical and can be fixed by the user.
Just setup the following to monitor all alerts > level 11.
1 - Database mail
http://craftydba.com/?p=1025
2 - Operator
http://craftydba.com/?p=1085
3 - Alerts
http://craftydba.com/?p=1099
Next time you get a alert, you should get an email with details.
If you want to be real fancy, you can have the alert call a job. Log the alert in the APPLICATION log and then send the email.