use*_*968 4 performance sql-server sql-server-2014
我有一个 SQLjob,它调用xp_cmdshell
用于通过脚本将 txt 文件转储到 ftp 站点。
有时它会失败并且作业被挂在可执行状态。通常我会终止会话并清除它。
但是,我有两个会话处于不确定状态。
sp_WHO2 53 -- running from 7/8/2018
Run Code Online (Sandbox Code Playgroud)
SP_WHO2 98 -- running from 6/16/2018
Run Code Online (Sandbox Code Playgroud)
作业状态显示它,Runnable
但命令是KILLED/ROLLBACK
。
Kill 53 with status only
Run Code Online (Sandbox Code Playgroud)
输出
Run Code Online (Sandbox Code Playgroud)SPID 53: transaction rollback in progress. Estimated rollback completion: 0%. Estimated time remaining: 0 seconds.
KILL 98 with status only
Run Code Online (Sandbox Code Playgroud)
输出
Run Code Online (Sandbox Code Playgroud)SPID 98: transaction rollback in progress. Estimated rollback completion: 0%. Estimated time remaining: 0 seconds.
我该如何清除这些会话?
我遇到了 SQL Server 的性能问题,这导致我参加了这些会议。我做了一些研究并指出我相信它会增加日志文件并导致性能问题。我不知道当前问题是否是因为这些会话,但它们是活跃的、昂贵的查询。所以我想从这里开始。我是这里的开发人员,我知道活动监视器在 SQL SERVER 2014 中已过时但我确实检查了活动监视器,下面是图像。
你能建议我怎么做吗?
我确实读过 Brent Ozar 写的关于这种情况的博客
-回滚:当你杀死一个会话时会发生什么?.
艰难地学习,寻找解决根本原因。
AK
You could try to kill the windows process that was spawned with xp_cmdshell
as that process is probably running and not handled by killing the spid from SQL Server. The way you describe it I would guess the ftp program is still running.
This is because the kill
command doesn't kill programs that were started out of process.
You could simulate the scenario like this:
In a SQL Query window start a process:
xp_cmdshell 'notepad.exe'
Run Code Online (Sandbox Code Playgroud)
and then after killing that spid I get the same output in sp_who2 as you
54 RUNNABLE Administrator hostname . master KILLED/ROLLBACK 0 0 07/24 14:23:02 Microsoft SQL Server Management Studio - Query 54 0
Run Code Online (Sandbox Code Playgroud)
But I still have a running notepad.exe process:
C:\Users\Administrator>tasklist | find "notepad"
notepad.exe 4676 Services 0 3 788 K
Run Code Online (Sandbox Code Playgroud)
Once I kill that notepad.exe process my SQL Server spid is gone too.
If you want to find out what process you need to kill process explorer should show it as a child process of sqlserver.exe like this (you might need to start procexp.exe as administrator):
归档时间: |
|
查看次数: |
13290 次 |
最近记录: |