SQL Server - difference between stopping and disabling Agent Jobs - sql-server

Can someone explain - didn't find it in MS's docs - what is the difference in behaviour of EXEC dbo.sp_stop_job and EXEC dbo.sp_update_job #enabled = 0? I'm preparing for AWS RDS reboot and need to turn off any job/ssis/dms that points to/from my RDS instance.
Goal is to stop any activity happening around RDS without brutal/forced connection break.

If you stop a job, you stop the currently running agent job. If you disable a job that means that the job will not start at it's next scheduled time.
Take, for example, a job that starts every hour, on the hour, and takes 10 minutes to complete. At 13:05 you stop the job; the process currently running is terminated (likely triggering rollbacks for any open transactions). The job will then run again at 14:00.
For the same job, at 16:01 you disable it. I believe, (though it's not documented that I could see) the job will continue running to completion, however, at 17:00 it will not start, and nor will it at any later dates until it is enabled (again).

Related

(SQL) Server Agent Job not stopping

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

How to stop Oracle dbms_job

My dbms_job has been running for nearly thirty days.
The number of total time keeps rising, but I can't find any info of the running job.
When I execute sql that is "select * from dba_jobs;", the result shows no job is running.
I set it to broken, but it doesn't work.
How can I stop this dbms_job safely?
DBA_JOBS lists all the jobs created in the database. You could use DBA_JOBS_RUNNING view to list all jobs that are currently running in the instance.
When I execute sql that is "select * from dba_jobs;", the result shows no job is running.
This shows all the jobs created using DBMS_JOBS package. The job might have created using DBMS_SCHEDULER package.
SQL> select job from user_jobs;
JOB
----------
99
I have created only one job using DBMS_JOBpackage which is called 99.
Others are created using DBMS_SCHEDULERpackage which can be seen using:
SQL> select job_name from user_scheduler_jobs;
As per the documentation-
Stopping a Job
Note that, once a job is started and running, there is no easy way to stop the job.
Its not easy to stop the job.
Don't know which version of Oracle database are you using. But starting with Oracle 10g You use the following query to list the scheduled jobs.
SQL>select * from all_scheduler_jobs;
ALL_SCHEDULER_JOBS
ALL_SCHEDULER_JOBS displays information about the Scheduler jobs accessible to the current user.More...
Use the following query to find the currently running job.
SQL>select job_name, session_id, running_instance, elapsed_time, cpu_used
from user_scheduler_running_jobs;
And to stop-
SQL>EXEC DBMS_SCHEDULER.STOP_JOB (job_name => 'JOB_NAME');
Short of killing the session, you're out of luck.
From the Documentation:
Note that, once a job is started and running, there is no easy way to stop the job.
That's one of the many reasons why you shouldn't use dbms_job anymore. Use dbms_scheduler instead.
checkout SID in "select * from DBA_JOBS_RUNNNG"
thats session ID
kill that session and thats it changes will be rolled back, so it can take "more" time to abort than letting it finish if that bulk update was 90% complete....

Kill Job Activity in SQL Server

There is job on our SQL Server. It was started and stopped after some time. However, the job still appears to be running even if it is not.
I can see it "is running" in Job Activity Monitor and also sysjobactivity (= there is no stop_execution_date field filled, but in fact nothing happens. I do not see it running in Activity Monitor.
How to effectively kill the job without need to restart whole server? Stopping the job via SSMS GUI does not work.

MSSQL Backup Immediately Suspended [BULKOP_BACKUP_DB]

Our production database server has stopped running the backup maintance plans...
The server has plenty of space, upon googling and futher investigation it appears the backups are being halted they moment they are started.
Running "Select * from Sys.dm_Exec_requests where command = 'Backup Database'" indicates the backup is being suspended due to 'DATABASE: 5 [BULKOP_BACKUP_DB]' with wait type of 'LCK_M_U'
I have tried searching for an answer to this, but nothing seems to apply in this case.
As i stated the server has plenty of disk space, and has been restarted, yet the backups are still immediatly suspened.
I'm all out of ideas, and would apreciate any input into helping me fix this 'issue'
Update: It seems it is waiting for session 77 to finish which is another backup, but it is 'Killed/Rollback' with percentage complete of 76% (doesnt appear to be changing) and a wait time of 267328092, trying to kill this prcoess results in 'SPID 77: transaction rollback in progress. Estimated rollback completion: 76%. Estimated time remaining: 86124 seconds.'
Update: Upon installing updates, trying some fixes, it appeared fixed, however on its second attempt it also stopped processing the backup, this time with a wait type of ASYNC_IO_COMPLETION...
any ideas?

Does SQL Server job wait to finish the currently executing call before starting the next schedule call? [duplicate]

If you schedule a SQL Server job to run every X number of minutes, and it does not finish the previous call before the # of minutes is up, will it skip the run since it is already running, or will it run two instances of the job doing the same steps?
The SQL Server agent checks whether the job is already running before starting a new iteration. If you have long running job and its schedule comes up, it would be skipped until the next interval.
You can try this for yourself. If you try to start a job that's already running, you will get an error to that effect.
I'm pretty sure it will skip it if it is running.
Which version of SQL Server are you using? This seems like a pretty easy thing to test. Set up a job with a WAITFOR in it that inserts a single row into a table and set up the job to run twice in quick succession (shorter than the WAITFOR DELAY).
When running such a test in SQL Server 2005 it skipped the run that was overlapped.

Resources