热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

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

当某个数据库文件空间用尽,做自动增长的时候,同一时间点只能有一个用户人员可以做文件自动增长动作,其他任务必须等待,此时会出现Latch资源的等待。使用sp_helpdb查看业务数据库时发现

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

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

image

 

顺便整理一下查看阻塞、会话状态及等待类型的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也贴出来,问题现象就更具体了。

QQ图片20150703083102

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.

推荐阅读
  • 构建Python自助式数据查询系统
    在现代数据密集型环境中,业务团队频繁需要从数据库中提取特定信息。为了提高效率并减少IT部门的工作负担,本文探讨了一种利用Python语言实现的自助数据查询工具的设计与实现。 ... [详细]
  • 本文详细介绍如何在Spring Boot项目中集成和使用JPA,涵盖JPA的基本概念、Spring Data JPA的功能以及具体的操作步骤,帮助开发者快速掌握这一强大的持久化技术。 ... [详细]
  • 设计模式系列-原型模式
    一、上篇回顾上篇创建者模式中,我们主要讲述了创建者的几类实现方案,和创建者模式的应用的场景和特点,创建者模式适合创建复杂的对象,并且这些对象的每个组成部分的详细创建步骤可以是动态的变化的,但 ... [详细]
  • 本文提供了解决在尝试重置MySQL root用户密码时遇到连接失败问题的方法,包括停止MySQL服务、以安全模式启动MySQL、手动更新用户表中的密码等步骤。 ... [详细]
  • MVC框架下使用DataGrid实现时间筛选与枚举填充
    本文介绍如何在ASP.NET MVC项目中利用DataGrid组件增强搜索功能,具体包括使用jQuery UI的DatePicker插件添加时间筛选条件,并通过枚举数据填充下拉列表。 ... [详细]
  • 本文档提供了详细的MySQL安装步骤,包括解压安装文件、选择安装类型、配置MySQL服务以及设置管理员密码等关键环节,帮助用户顺利完成MySQL的安装。 ... [详细]
  • SQLite是一种轻量级的关系型数据库管理系统,尽管体积小巧,却能支持高达2TB的数据库容量,每个数据库以单个文件形式存储。本文将详细介绍SQLite在Android开发中的应用,包括其数据存储机制、事务处理方式及数据类型的动态特性。 ... [详细]
  • 时序数据是指按时间顺序排列的数据集。通过时间轴上的数据点连接,可以构建多维度报表,揭示数据的趋势、规律及异常情况。 ... [详细]
  • 解决 Pytest 运行时出现 FileNotFoundError 的方法
    在使用 Pytest 进行测试时,可能会遇到 FileNotFoundError 错误,提示无法找到指定的文件或目录。本文将探讨该错误的原因及解决方案。 ... [详细]
  • 本文详细介绍了在 Windows 7 上安装和配置 PHP 5.4 的 Memcached 分布式缓存系统的方法,旨在减少数据库的频繁访问,提高应用程序的响应速度。 ... [详细]
  • 深入解析轻量级数据库 SQL Server Express LocalDB
    本文详细介绍了 SQL Server Express LocalDB,这是一种轻量级的本地 T-SQL 数据库解决方案,特别适合开发环境使用。文章还探讨了 LocalDB 与其他轻量级数据库的对比,并提供了安装和连接 LocalDB 的步骤。 ... [详细]
  • 本文详细介绍了Oracle RMAN中的增量备份机制,重点解析了差异增量和累积增量备份的概念及其在不同Oracle版本中的实现。通过对比两种备份方式的特点,帮助读者选择合适的备份策略。 ... [详细]
  • 本文介绍了JSP的基本概念、常用标签及其功能,并通过示例详细说明了如何在JSP页面中使用Java代码。 ... [详细]
  • 转自:http:blog.sina.com.cnsblog_67419c420100vmkt.html 1.为什么要使用blocks将一个blocks作为函数或者方法的参数传递,可 ... [详细]
  • 本文档详细介绍了Excel VBA编程中的基本语法,包括循环结构、条件判断、数据处理以及用户界面设计等内容,旨在帮助初学者快速掌握VBA编程技巧。 ... [详细]
author-avatar
竹叶清2012
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有