当某个数据库文件空间用尽,做自动增长的时候,同一时间点只能有一个用户人员可以做文件自动增长动作,其他任务必须等待,此时会出现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. codeforces 597C (树状数组+DP)

    题目链接:http://codeforces.com/contest/597/problem/C 思路:dp[i][j]表示长度为i,以j结尾的上升子序列,则有dp[i][j]= ∑dp[i-1][k ...

  2. Android Material Design Ripple Effect在Android5.0(SDK=21)以下Android版本崩溃问题解决

    Android Material Design Ripple Effect在Android5.0(SDK=21)以下Android版本崩溃问题解决 附录1的Android Ripple Effect水 ...

  3. 第一个Sprint冲刺第八天

    讨论成员:邵家文.李新.朱浩龙.陈俊金 讨论地点:宿舍 解决问题:计分问题 燃尽图

  4. Core Java Volume I — 4.7. Packages

    4.7. PackagesJava allows you to group classes in a collection called a package. Packages are conveni ...

  5. java 读取XML文件作为配置文件

    首先,贴上自己的实例: XML文件:NewFile.xml(该文件与src目录同级) <?xml version="1.0" encoding="UTF-8&quo ...

  6. httpclient 发送一个请求

    httpclient版本 4.1 发送一个post请求 public static JSONObject post(String url,JSONObject json){ HttpClient cl ...

  7. test Windows Live Writer

    1, 下载Live Writer http://windows.microsoft.com/zh-cn/windows-live/essentials-other#essentials=overvie ...

  8. 使用apt-get方式为Kubuntu安装PHP+MYSQL+Apache

    相信很多搭过动态网站的朋友都知道怎么搭web服务器, 本人是linux新手, 以前在windows是直接使用集成的wamp server, 所以在linux没有亲手搭过. 本系统: ubuntu 12 ...

  9. 快速掌握grep命令及正则表达式

    Linux系统自带了支持拓展正则表达式的 GNU 版本 grep 工具,所有的Linux发行版中均默认安装grep ,grep 命令被用来检索一台服务器或工作站上任何位置的文本信息,如何在 Linux ...

  10. H-ui小技巧

    图片上传时修改错误提示信息(图超过允许上传的图片的数量):在webuploader.js中修改