当某个数据库文件空间用尽,做自动增长的时候,同一时间点只能有一个用户人员可以做文件自动增长动作,其他任务必须等待,此时会出现Latch资源的等待。使用sp_helpdb查看业务数据库时发现:该数据库设置不合理,数据文件每次增长2M,日志文件每次增长10%,且分别设置了最大限制。修改为每次增长200M,不限制大小,系统恢复正常,问题解决。

SqlServer阻塞时的等待类型如下:

顺便整理一下查看阻塞、会话状态及等待类型的SQL脚本:

-- 查看SQL阻塞信息
with tmp as (
select * from master..sysprocesses t where t.blocked != 0
union all
select b.* from master..sysprocesses b
join tmp t on b.spid = t.blocked
)
select t.spid, t.blocked, t.status, t.waittype, t.lastwaittype, t.waitresource, t.waittime
, DB_NAME(t.dbid) DbName, t.login_time, t.loginame, t.program_name, dc.text
from (select spid from tmp group by spid) s
join master..sysprocesses t on s.spid = t.spid
cross apply master.sys.dm_exec_sql_text(t.sql_handle) dc -- 查看所有会话的状态、等待类型及当前正在执行SQL脚本
select t.spid, t.kpid, t.blocked, t.status, t.waittype, t.lastwaittype, t.waitresource, t.waittime
, DB_NAME(t.dbid) DbName, t.login_time, t.last_batch, t.loginame, t.program_name, t.hostname, t.hostprocess
, t.cmd, t.stmt_start, t.stmt_end, t.request_id, dc.text
from master.sys.sysprocesses t
 outer apply master.sys.dm_exec_sql_text(t.sql_handle) dc
where t.spid >= 50

补充,昨天又有项目发生类似问题,将SqlServer的errorlog也贴出来,问题现象就更具体了。

07/01/2015 16:44:56,spid55,未知,A time-out occurred while waiting for buffer latch -- type 2<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x000000000097DB88 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000007C2E08. Not continuing to wait.
07/01/2015 16:44:47,spid51,未知,A time-out occurred while waiting for buffer latch -- type 2<c/> bp 00000000D2FC3AC0<c/> page 1:117692<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594070827008<c/> task 0x000000000053F708 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000007C34C8. Not continuing to wait.
07/01/2015 16:44:41,spid77,未知,A time-out occurred while waiting for buffer latch -- type 2<c/> bp 00000000D2FC3AC0<c/> page 1:117692<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594070827008<c/> task 0x00000000F380DB88 : 0<c/> waittime 300<c/> flags 0x1a<c/> owning task 0x00000000007C34C8. Not continuing to wait.
07/01/2015 16:44:32,spid60,未知,Timeout occurred while waiting for latch: class 'LOG_MANAGER'<c/> id 000000000C980AE0<c/> type 4<c/> Task 0x00000000007C34C8 : 0<c/> waittime 300<c/> flags 0x1a<c/> owning task 0x00000000007C2E08. Continuing to wait.
07/01/2015 16:43:56,spid54,未知,A time-out occurred while waiting for buffer latch -- type 2<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x00000000BD674E08 : 0<c/> waittime 300<c/> flags 0x1a<c/> owning task 0x00000000007C2E08. Not continuing to wait.
07/01/2015 14:46:39,spid62,未知,Autogrow of file 'cwbase001_log' in database 'cwbase001' took 568576 milliseconds. Consider using ALTER DATABASE to set a smaller FILEGROWTH for this file.
07/01/2015 14:45:54,spid66,未知,A time-out occurred while waiting for buffer latch -- type 2<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x00000000007A9DC8 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000007C2E08. Not continuing to wait.
07/01/2015 14:45:46,spid70,未知,A time-out occurred while waiting for buffer latch -- type 2<c/> bp 00000000CAFE1880<c/> page 1:113858<c/> stat 0xc0010b<c/> database id: 10<c/> allocation unit Id: 72057594070827008<c/> task 0x00000000BD674748 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000BD674508. Not continuing to wait.
07/01/2015 14:45:28,spid59,未知,A time-out occurred while waiting for buffer latch -- type 2<c/> bp 00000000CAFE1880<c/> page 1:113858<c/> stat 0xc0010b<c/> database id: 10<c/> allocation unit Id: 72057594070827008<c/> task 0x00000000007C2BC8 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000BD674508. Not continuing to wait.
07/01/2015 14:45:24,spid67,未知,A time-out occurred while waiting for buffer latch -- type 2<c/> bp 00000000CAFE1880<c/> page 1:113858<c/> stat 0xc0010b<c/> database id: 10<c/> allocation unit Id: 72057594070827008<c/> task 0x00000000F380CBC8 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000BD674508. Not continuing to wait.
07/01/2015 14:44:54,spid65,未知,A time-out occurred while waiting for buffer latch -- type 2<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x000000000053EE08 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000007C2E08. Not continuing to wait.
07/01/2015 14:44:40,spid64,未知,A time-out occurred while waiting for buffer latch -- type 2<c/> bp 00000000CAFE1880<c/> page 1:113858<c/> stat 0xc0010b<c/> database id: 10<c/> allocation unit Id: 72057594070827008<c/> task 0x00000000BD674E08 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000BD674508. Not continuing to wait.
07/01/2015 14:43:54,spid63,未知,A time-out occurred while waiting for buffer latch -- type 2<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x000000000053F708 : 0<c/> waittime 300<c/> flags 0x1a<c/> owning task 0x00000000007C2E08. Not continuing to wait.
07/01/2015 14:43:50,spid60,未知,Timeout occurred while waiting for latch: class 'LOG_MANAGER'<c/> id 000000000C980AE0<c/> type 4<c/> Task 0x00000000007A9288 : 0<c/> waittime 300<c/> flags 0x1a<c/> owning task 0x00000000BD674508. Continuing to wait.
07/01/2015 14:43:13,spid54,未知,A time-out occurred while waiting for buffer latch -- type 2<c/> bp 00000000CAFE1880<c/> page 1:113858<c/> stat 0xc0010b<c/> database id: 10<c/> allocation unit Id: 72057594070827008<c/> task 0x00000000B2F4C988 : 0<c/> waittime 300<c/> flags 0x1a<c/> owning task 0x00000000BD674508. Not continuing to wait.
07/01/2015 14:42:54,spid53,未知,Timeout occurred while waiting for latch: class 'LOG_MANAGER'<c/> id 000000000C980AE0<c/> type 4<c/> Task 0x00000000007C2E08 : 0<c/> waittime 300<c/> flags 0x1a<c/> owning task 0x00000000BD674508. Continuing to wait.
07/01/2015 13:01:53,spid18s,未知,Autogrow of file 'cwbase001_log' in database 'cwbase001' took 961310 milliseconds. Consider using ALTER DATABASE to set a smaller FILEGROWTH for this file.
07/01/2015 13:01:53,spid60,未知,A time-out occurred while waiting for buffer latch -- type 2<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x00000000B2F4CBC8 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000B2F4C2C8. Not continuing to wait.
07/01/2015 13:01:50,spid90,未知,A time-out occurred while waiting for buffer latch -- type 4<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x00000000F535C2C8 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000B2F4C2C8. Not continuing to wait.
07/01/2015 13:01:50,spid113,未知,A time-out occurred while waiting for buffer latch -- type 4<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x00000000F380D048 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000B2F4C2C8. Not continuing to wait.
07/01/2015 13:01:50,spid111,未知,A time-out occurred while waiting for buffer latch -- type 4<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x00000000B2F4D4C8 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000B2F4C2C8. Not continuing to wait.
07/01/2015 13:01:50,spid114,未知,A time-out occurred while waiting for buffer latch -- type 4<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x00000000F535CE08 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000B2F4C2C8. Not continuing to wait.
07/01/2015 13:01:50,spid125,未知,A time-out occurred while waiting for buffer latch -- type 2<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x00000000F380DB88 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000B2F4C2C8. Not continuing to wait.
07/01/2015 13:01:50,spid120,未知,A time-out occurred while waiting for buffer latch -- type 4<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x00000000F535C748 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000B2F4C2C8. Not continuing to wait.
07/01/2015 13:01:50,spid55,未知,A time-out occurred while waiting for buffer latch -- type 4<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x00000000F380CBC8 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000B2F4C2C8. Not continuing to wait.
07/01/2015 13:01:50,spid117,未知,A time-out occurred while waiting for buffer latch -- type 4<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x00000000007A9288 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000B2F4C2C8. Not continuing to wait.
07/01/2015 13:01:50,spid59,未知,A time-out occurred while waiting for buffer latch -- type 4<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x00000000BD674E08 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000B2F4C2C8. Not continuing to wait.
07/01/2015 13:01:50,spid109,未知,A time-out occurred while waiting for buffer latch -- type 4<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x000000000053EE08 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000B2F4C2C8. Not continuing to wait.
07/01/2015 13:01:50,spid66,未知,A time-out occurred while waiting for buffer latch -- type 4<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x00000000007C2E08 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000B2F4C2C8. Not continuing to wait.
07/01/2015 13:01:50,spid106,未知,A time-out occurred while waiting for buffer latch -- type 2<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x000000000053F708 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000B2F4C2C8. Not continuing to wait.
07/01/2015 13:01:50,spid57,未知,A time-out occurred while waiting for buffer latch -- type 2<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x00000000BD675DC8 : 0<c/> waittime 300<c/> flags 0x1a<c/> owning task 0x00000000B2F4C2C8. Not continuing to wait.
07/01/2015 12:56:50,spid109,未知,A time-out occurred while waiting for buffer latch -- type 2<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x000000000053EE08 : 0<c/> waittime 300<c/> flags 0x1a<c/> owning task 0x00000000F380D048. Not continuing to wait.
07/01/2015 12:51:17,spid75,未知,A time-out occurred while waiting for buffer latch -- type 2<c/> bp 00000000CAFE1880<c/> page 1:113858<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594070827008<c/> task 0x000000000053FB88 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000007C3B88. Not continuing to wait.
07/01/2015 12:51:17,spid88,未知,A time-out occurred while waiting for buffer latch -- type 2<c/> bp 00000000CAFE1880<c/> page 1:113858<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594070827008<c/> task 0x00000000F535D708 : 0<c/> waittime 300<c/> flags 0x1a<c/> owning task 0x00000000007C3B88. Not continuing to wait.
07/01/2015 12:45:53,spid54,未知,A time-out occurred while waiting for buffer latch -- type 2<c/> bp 00000000D9FD9540<c/> page 1:3783<c/> stat 0xc00109<c/> database id: 10<c/> allocation unit Id: 72057594043629568<c/> task 0x00000000F380D288 : 0<c/> waittime 300<c/> flags 0x3a<c/> owning task 0x00000000F380D048. Not continuing to wait.

SqlServer性能急剧下降,查看所有会话的状态及等待类型---Latch_Ex的更多相关文章

  1. SqlServer性能优化,查看CPU、内存占用大的会话及SQL语句

    1,查看CPU占用量最高的会话及SQL语句   select spid,cmd,cpu,physical_io,memusage, (select top 1 [text] from ::fn_get ...

  2. 了解 .NET 的默认 TaskScheduler 和线程池(ThreadPool)设置,避免让 Task.Run 的性能急剧降低

    .NET Framework 4.5 开始引入 Task.Run,它可以很方便的帮助我们使用 async / await 语法,同时还使用线程池来帮助我们管理线程.以至于我们编写异步代码可以像编写同步 ...

  3. SQLSERVER性能监控级别步骤

    SQLSERVER性能监控级别步骤 下面先用一幅图描述一下有哪些步骤和顺序 1.识别瓶颈 识别瓶颈的原因包括多个方面,例如,资源不足,需要添加或升级硬件: 工作负荷在同类资源之间分布不均匀,例如,一个 ...

  4. SQLServer性能优化之---数据库级日记监控

    上节回顾:https://www.cnblogs.com/dotnetcrazy/p/11029323.html 4.6.6.SQLServer监控 脚本示意:https://github.com/l ...

  5. 01.SQLServer性能优化之----强大的文件组----分盘存储

    汇总篇:http://www.cnblogs.com/dunitian/p/4822808.html#tsql 文章内容皆自己的理解,如有不足之处欢迎指正~谢谢 前天有学弟问逆天:“逆天,有没有一种方 ...

  6. 知方可补不足~sqlserver中使用sp_who查看sql的进程

    回到目录 在SQLSERVER中每个会话,即每个查询分析器窗口都会产生一个SQL进程,对于那些持续时间短的进程,它们转瞬即失,而对于持续时间比较长的,我们需要希望查看它的运行状态,就可以借助SQL提供 ...

  7. SQLServer性能调优3之索引(Index)的维护

    前言 前一篇的文章介绍了通过建立索引来提高数据库的查询性能,这其实只是个开始.后续如果缺少适当的维护,你先前建立的索引甚至会成为拖累,成为数据库性能的下降的帮凶. 查找碎片 消除碎片可能是索引维护最常 ...

  8. 03.SQLServer性能优化之---存储优化系列

    汇总篇:http://www.cnblogs.com/dunitian/p/4822808.html#tsql 概  述:http://www.cnblogs.com/dunitian/p/60413 ...

  9. 02.SQLServer性能优化之---牛逼的OSQL----大数据导入

    汇总篇:http://www.cnblogs.com/dunitian/p/4822808.html#tsql 上一篇:01.SQLServer性能优化之----强大的文件组----分盘存储 http ...

随机推荐

  1. HDU5763 another meaning -(KMP+DP)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5763 思路:dp[i]表示前i个字符组成的字符串所表示的意思数量,则当匹配时dp[i]=dp[i-1] ...

  2. 4 Values whose Sum is 0_upper_bound&&ower_bound

    Description The SUM problem can be formulated as follows: given four lists A, B, C, D of integer val ...

  3. Inno Setup 在安装程序开始前和卸载程序开始前,检查并关闭运行的进程

    (2011-12-29 11:54:56) 转载▼ 标签: innosetup it 分类: 开发工具经验累积 Inno Setup在安装程序前,如果有使用的进程在运行,会有错误提示,而使得Insta ...

  4. Aborting commit: 'XXXXXXXX'remains in conflict错误

    今天在提交项目文件到本地SVN时提示错误如下: 过期:”global.php“在事务”21-1“, You have to update your working copy first. 运行upda ...

  5. Spring3整合Hibernate4-我们到底能走多远系列(30)

    我们到底能走多远系列(30) 扯淡: 30篇啦!从2012-08-15开始的系列,东平西凑将近一年的时间也就这么几篇.目标的100篇,按这个速度也要再搞两年呢. 发博客果然不是件容易的事,怪不得更多的 ...

  6. (基础篇)PHP与JavaScript交互

    一.了解javascript Javascript是脚本编程语言,支持WEB应用程序的客户端和服务器端构件的开发,在WEB系统中得到了非常广泛的应用. 1. 什么是javascript Javascr ...

  7. js 下载文件 window.location.href

    window.location.href ="../../pages2/assessmentplan/exportPointAsessment.do?planId="+planId ...

  8. C++ Primer : 第十二章 : 动态内存之shared_ptr类

    在C++中,动态内存是的管理是通过一对运算符来完成的:new  ,在动态内存中为对象分配空间并返回一个指向该对象的指针,delete接受一个动态对象的指针,销毁该对象,并释放该对象关联的内存. 动态内 ...

  9. Codeforces Round #116 (Div. 2, ACM-ICPC Rules)

    Codeforces Round #116 (Div. 2, ACM-ICPC Rules) 代码 Codeforces Round #116 (Div. 2, ACM-ICPC Rules) A. ...

  10. HDU5934 Bomb(2016杭州CCPC第二题)(强连通缩点)

    Bomb Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...