返回顶部
首页 > 资讯 > 数据库 >YourSQLDba低版本的一个Bug的浅析
  • 238
分享到

YourSQLDba低版本的一个Bug的浅析

YourSQLDba低版本的一个Bug的浅析 2019-06-19 23:06:02 238人浏览 才女
摘要

帮人分析解决一个YoursqlDba备份报错问题,个人觉得有点意思,顺手记录一下分析思路,大体解决思路如下:   首先,找到YourSQLDba作业YourSQLDba_FullBackups_And_Maintenance的报错

YourSQLDba低版本的一个Bug的浅析

帮人分析解决一个YoursqlDba备份报错问题,个人觉得有点意思,顺手记录一下分析思路,大体解决思路如下:

 

首先,找到YourSQLDba作业YourSQLDba_FullBackups_And_Maintenance的报错邮件或者作业的错误日志信息,检查YourSQLDba出错的详细信息。

 

YOURSQLDBA.MAINT.ShowHistoryErrors 96

 

发现YourSQLDba在更新统计信息是遇到错误,如下所示

 

  yMaint.UpdateStats
  update statistics selected
  update statistics [model].[dbo].[ServiceBrokerQueue] WITH sample 100 PERCENT
  Error 2706, Severity 16, level 6 : Table "ServiceBrokerQueue" does not exist.

 

 

检查发现这个对象是queue,根本不是表,所以更新统计信息会出错。

 

clip_image001

 

那么YourSQLDba怎么会更新queue对象的统计信息呢?我首先检查了一下YourSQLDba的版本信息。当前数据库服务器上的YourSQLDba是相当老的一个版本了。然后我就去检查YourSQLDba的代码

 

 

Exec YourSQLDba.Install.PrintVersionInfo
 
========================================
 
YourSQLDba version: 5.0.2 2012-06-12

 

YourSQLDba更新统计信息是通过[yMaint].[UpdateStats]来更新统计,于是检查代码,发现获取要更新统计信息的对象是通过下面脚本获取的。首先将要更新统计信息的对象放到临时表#TableNames中去,然后生成更新统计信息的脚本。

 

-- makes query boilerplate with replacable parameter identified by
-- labels between "<" et ">"
-- this query select table for which to perfORM update statistics
truncate table #TableNames
set @sql =
"
 set nocount on
 ;With
   TableSizeStats as
 (
 select 
   object_schema_name(Ps.object_id, db_id("")) as scn --collate 
 , object_name(Ps.object_id, db_id("")) as tb --collate 
 , Sum(Ps.Page_count) as Pg
From
  sys.dm_db_index_physical_stats (db_id(""), NULL, NULL, NULL, "LIMITED") Ps
Group by 
  Ps.object_id  
)
Insert into #tableNames (scn, tb, seq, sampling)
Select 
  scn
, tb
, row_number() over (order by scn, tb) as seq
, Case 
    When pg > 200001 Then "10"
    When Pg between 50001 and 200000 Then "20"
    When Pg between 5001 and 50000 Then "30"
    else "100"
  End  
From 
  TableSizeStats
where (abs(checksum(tb)) % ) = 

 

这个脚本会将queue类型的对象也放入临时表,所以明显是个Bug,不过YourSQLDba后续的版本已经Fix掉这个Bug了。如下所示,后续的版本就加上条件过滤了,只获取表和视图的数据。所以遇到这个问题,只需要升级YourSQLDba的版本就好了

 

 

   

-- makes query boilerplate with replacable parameter identified by
-- labels between "<" et ">"
-- this query select table for which to perform update statistics
truncate table #TableNames
set @sql =
"
 Use []
 set nocount on
 ;With
   TableSizeStats as
 (
 select 
   object_schema_name(Ps.object_id) as scn --collate 
 , object_name(Ps.object_id) as tb --collate 
 , Sum(Ps.Page_count) as Pg
From
  sys.dm_db_index_physical_stats (db_id(""), NULL, NULL, NULL, "LIMITED") Ps
Where (   OBJECTPROPERTYEX ( Ps.object_id , "IsTable" ) = 1
       Or OBJECTPROPERTYEX ( Ps.object_id , "IsView" ) = 1)
Group by 
  Ps.object_id  
)
Insert into #tableNames (scn, tb, seq, sampling)
Select 
  scn
, tb
, row_number() over (order by scn, tb) as seq
, Case 
    When Pg > 5000001 Then "0"
    When Pg between 1000001 and 5000000 Then "1"
    When Pg between 500001 and 1000000 Then "5"
    When pg between 200001 and 500000 Then "10"
    When Pg between 50001 and 200000 Then "20"
    When Pg between 5001 and 50000 Then "30"
    else "100"
  End  
From 
  TableSizeStats
where scn is not null and tb is not null and (abs(checksum(tb)) % ) = 

您可能感兴趣的文档:

--结束END--

本文标题: YourSQLDba低版本的一个Bug的浅析

本文链接: https://lsjlt.com/news/5972.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作