Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

unable to stop dtexec when called from batch file

$
0
0

Hi All,

I've noticed some strange behavior in SSIS (2008R2) that I was hoping someone could explain.

The problem (if you can call it one is as such).

I have a job which executes a SSIS package. It does not do so directly but rather calls a windows batch file (.bat) which in turn calls the SSIS package using the 32bit dtexec.

If I end job using the msdb.dbo.sp_end_job proc the job ends successfully bit I notice the dtexec process still lingering in the memory.

In the job steps, if instead of calling the batch file, I was to directly execute the package using the same 32bit dtexec - This time ending the job using sp_end_job does kill the dtexec process from memory.

Any idea why this is so?

If you would like to reproduce this, you could do the following

Create a package (say TestPackage.dtsx) with a single script task as follow

while (1==1)
{
System.Threading.Thread.Sleep(10000);
}

Then create a batch file(say TestPackageBatch.bat to run this package using 32bit dtexec

"C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\DTExec.exe" /f "C:\Test\TestPackage.dtsx"

Create two jobs

BatchTestJob = This one should have a single operating system (CmdExec) step that calls the batch file "C:\Test\TestPackageBatch.bat"

TestJob = This one should have a single operating system (CmdExec) step that calls the package using the 32bit dtexec using the command "C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\DTExec.exe" /f "C:\Test\TestPackage.dtsx"

Once done do the following in sequence

1. Run BatchTestJob
In the task manager you will notice both a cmd process (for the bat file I assume) & a dtexec process (note down the PID's if you want)

2. Run TestJob  
In the task manager you will notice another dtexec process (note down the PID if you want)

3. Execute msdb.dbo.sp_end_job 'TestJob' to end the 2nd job. You will notice that the dtexec process that was created as part of step 2 above will be terminated i.e. it no longer shows in the task manager

4. Execute msdb.dbo.sp_end_job 'BatchTestJob' to end the 1st job. You will notice that the cmd process that was created as part of step 1 above will be terminated i.e. it no longer shows in the task manager. However the dtexec will continue to exist unless you manually end it

I would be really grateful if someone could explain this behavior.

What I found even strange was if you open a separate cmd window and execute the package using "C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\DTExec.exe" /f "C:\Test\TestPackage.dtsx"

the package beings to execute. If you try to terminate it by ctrl + c you will notice the message
       DTExec: Stopping the package execution.

However the package continues to execute and it never ends. This is a known issue which Microsoft say on the following link is by design http://connect.microsoft.com/SQLServer/feedback/details/272120/msit-mso-cannot-stop-ssis-package-mid-statement-when-using-dtexec 

Something about atomic operations and how then cannot be stopped mid way. Fine - so it is treating my infinite loop script task as an atomic operation and hence not ending the package until that completes. So why does this not apply to step 3 above. i.e. there it ended the job & process even though it was in between the atomic operation

Further to this - If you were to close the cmd window using the close window button - the dtexec process is stopped. i.e. when the cmd process is ended so is the dtexec process that was called from within. By the same logic should step 4 above not achieve the same result i.e. ending the 'BatchTestJob' (which has the effect of ending the cmd process) also result in ending of the dtexec process?

Thanks for reading my lengthy post. Any thoughts would be very much appreciated

Regards,
Leighton

 




Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>