当某个数据库文件空间用尽,做自动增长的时候,同一时间点只能有一个用户人员可以做文件自动增长动作,其他任务必须等待,此时会出现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. 4、C#基础整理(if语句经典习题)

    1.用 if 判断输入的是否是空格键的方法:(Console.ReadKey()的用法) ConsoleKeyInfo readkey = Console.ReadKey(); Console.Wri ...

  2. PHP url重定向

    1.使用header()函数 PHP的 HTTP相关函数种提供了一个 header()函数,首先要清楚,header()函数必须放在php程序的开头部分,而且之前不能有另外的 header() 函数或 ...

  3. Qt5 添加右键菜单简单测试

    1.在.h文件中包含相关头文件 #include <QMenu> #include <QContextMenuEvent> 2.在.h文件中定义动作对象 QAction *ed ...

  4. python内置的数据结构

    详解列表List 这里是列表对象方法的清单: list.append(x) 添加一个元素到列表的末尾.相当于a[len(a):] = [x]. list.extend(L) 将给定列表L中的所有元素附 ...

  5. ui-bootstrap-tpls-0.11.0.min.js

  6. 使用AjaxPro

    1:后台注册 protected void Page_Load(object sender, EventArgs e) { AjaxPro.Utility.RegisterTypeForAjax(ty ...

  7. iOS学习笔记---oc语言第五天

    字典,数组 ,集排序 一.字典类 存储以下数据 name:张三; sex:男;age:18 film:风暴; playcount:10000次;price:60元 字典类用于保存具有映射关系(key- ...

  8. Android高效加载大图,多图解决方案,有效避免程序OOM异常

    收藏自:http://blog.csdn.net/guolin_blog/article/details/9316683 谷歌官方文档:http://developer.android.com/tra ...

  9. 感知机学习算法 python实现

    参考李航<统计学习方法> 一开始的感知机章节,看着不太复杂就实现一下... """ 感知机学习算法的原始形式 例2.1 """ ...

  10. ZOJ 3804--解题报告

    题目相关: 3804相关链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5336 宠物(minion)在N*M的矩形玩游戏 ...