代码改变世界

Reporting Services 错误案例一则

2015-02-03 00:25  潇湘隐者  阅读(4769)  评论(0编辑  收藏  举报

    遇到一个有意思的Reporting Services报表的案例,在2015-01-30号的凌晨20分左右的时候,有人发现Reporting Services的速度非常慢,而且最后有抛出异常,当时不知道什么情况。只是记录了其中一张报表的名字,以及出错信息截图。如下所示:

clipboard

 

     第二天,我首先通过下面SQL查看这张报表在2015-01-30 00:00到2015-01-30 02:00这段时间的执行记录,如下所示,正常情况下,3~5秒报表出来,不正常情况下整个报表耗费了接近60多秒,很奇怪的是TimeDataRetrieval的时间居然为0,大家都知道TimeDataRetrieval、TimeProcessing、TimeRendering分别表示检索数据、处理报表以及呈现报表所用的毫秒数(SQL里面,我将单位转化为秒)。但是TimeStart, TimeEnd的时间差(报表进程的持续时段的开始时间和结束时间)居然耗费了60多秒,让我很是纳闷,不太明白,照理来说,TimeDataRetrieval、TimeProcessing、TimeRendering三者的和应该接近于TimeEnd减去TimeStart的差,但是这里的情况明显不对头,那么究竟发生了什么事情呢,这张报表不是发生了异常吗,于是我找到了日志文件C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\LogFiles\ReportServer__01_30_2015_00_00_46.log

clipboard[1]

USE [ReportServer];
GO
 
SELECT  C.Name                         AS ReportName
       ,E.ReportID                     AS ReportID
       ,E.UserName                     AS UserName
       ,E.Format                       AS Format
       ,E.Parameters                   AS Parameters
       ,E.TimeStart                    AS TimeStart
       ,E.TimeEnd                      AS TimeEnd
       ,E.TimeDataRetrieval*1.0/1000   AS TimeDataRetrieval
       ,E.TimeProcessing*1.0/1000      AS TimeProcessing
       ,E.TimeRendering*1.0/1000       AS TimeRendering
       ,DATEDIFF(SECOND, TimeStart, TimeEnd)
                                       AS  CostTime
FROM ReportServer.dbo.ExecutionLog E WITH(NOLOCK)
INNER JOIN ReportServer.dbo.Catalog C WITH(NOLOCK)ON E.ReportID = C.ItemID
WHERE C.Name ='JOReportZH_FTYEMI'
   AND E.TimeStart > CAST('2015-01-30 00:00' AS DATETIME)
   AND E.TimeStart <= CAST('2015-01-30 02:00' AS DATETIME)
ORDER BY TimeStart DESC

 

如下所示,因为当时Oracle数据有异常,导致连接数据库时出现”ORA-12602: TNS: 达到连接共享限制“的错误。然后分析日志发现,Reporting Service进程在获取数据出现异常的情况下,有个错误处理机制让它继续尝试访问数据库,进行了多次尝试后才最终将异常抛出,这也是为什么TimeDataRetrieval的时间居然为0。TimeStart, TimeEnd的时间差(指示报表进程的持续时段的开始时间和结束时间)耗费了60多秒的缘故。到此谜底终于揭开!困扰我的疑问豁然开朗!

ReportServer__01_30_2015_00_00_46.log文件里面的部分内容如下所示:

w3wp!library!18!01/30/2015-00:03:28:: i INFO: Call to RenderFirst( '/JO/EEL/JOReportZH_FTYEMI' )
w3wp!runningjobs!d!30/01/2015-00:04:07:: i INFO: Adding: 1 running jobs to the database
w3wp!library!8!01/30/2015-00:04:09:: i INFO: Call to RenderFirst( '/JO/EEL/JOReportZH_FTYEMI' )
w3wp!processing!18!2015/1/30-00:04:31:: e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: 对数据集“SELECT_MATRIX_OPT”执行查询失败。, ;
Info: Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: 对数据集“SELECT_MATRIX_OPT”执行查询失败。 ---> System.Data.OracleClient.OracleException: ORA-12602: TNS: 达到连接共享限制

   at System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle errorHandle, Int32 rc)
   at System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle statementHandle, CommandBehavior behavior, Boolean needRowid, OciRowidDescriptor& rowidDescriptor, ArrayList& resultParameterOrdinals)
   at System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle statementHandle, CommandBehavior behavior, ArrayList& resultParameterOrdinals)
   at System.Data.OracleClient.OracleCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.OracleClient.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.ReportingServices.DataExtensions.OracleCommandWrapperExtension.ExecuteReader(CommandBehavior behavior)
   at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RuntimeDataSetNode.RunDataSetQuery()
   --- End of inner exception stack trace ---
w3wp!processing!18!2015/1/30-00:04:31:: e ERROR: An exception has occurred in data source 'SELECT_MATRIX_OPT'. Details: Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: 对数据集“SELECT_MATRIX_OPT”执行查询失败。 ---> System.Data.OracleClient.OracleException: ORA-12602: TNS: 达到连接共享限制

w3wp!processing!18!2015/1/30-00:04:31:: i INFO: Merge abort handler called. Aborting data sources ...
w3wp!dataextension!18!2015/1/30-00:04:31:: w WARN: CommandWrapper.Cancel not called, connection is not valid
w3wp!processing!18!2015/1/30-00:04:31:: e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.ProcessingAbortedException: 处理报表时出错。, ;
Info: Microsoft.ReportingServices.ReportProcessing.ProcessingAbortedException: 处理报表时出错。 ---> Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: 对数据集“SELECT_MATRIX_OPT”执行查询失败。 ---> System.Data.OracleClient.OracleException: ORA-12602: TNS: 达到连接共享限制

   --- End of inner exception stack trace ---
w3wp!processing!18!2015/1/30-00:04:31:: w WARN: Data source '1.90': Report processing has been aborted.
w3wp!processing!18!2015/1/30-00:04:31:: e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.ProcessingAbortedException: 处理报表时出错。, ;
Info: Microsoft.ReportingServices.ReportProcessing.ProcessingAbortedException: 处理报表时出错。 ---> Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: 对数据集“SELECT_MATRIX_OPT”执行查询失败。 ---> System.Data.OracleClient.OracleException: ORA-12602: TNS: 达到连接共享限制

   --- End of inner exception stack trace ---
w3wp!webserver!18!01/30/2015-00:04:31:: e ERROR: Reporting Services error Microsoft.ReportingServices.Diagnostics.Utilities.RSException: 处理报表时出错。 ---> Microsoft.ReportingServices.ReportProcessing.ProcessingAbortedException: 处理报表时出错。 ---> Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: 对数据集“SELECT_MATRIX_OPT”执行查询失败。 ---> System.Data.OracleClient.OracleException: ORA-12602: TNS: 达到连接共享限制

w3wp!library!d!01/30/2015-00:04:53:: i INFO: Call to RenderFirst( '/JO/EEL/JOReportZH_FTYEMI' )
w3wp!runningjobs!1!30/01/2015-00:05:07:: i INFO: RunningJobContext.IsClientConnected; found orphaned request
w3wp!runningjobs!18!30/01/2015-00:05:07:: i INFO: Adding: 1 running jobs to the database
w3wp!runningjobs!1!30/01/2015-00:05:07:: i INFO: RunningJobContext.IsClientConnected; found orphaned request
w3wp!processing!8!2015/1/30-00:05:13:: e ERROR: Throwing Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: 对数据集“SELECT_MATRIX_OPT”执行查询失败。, ;
Info: Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: 对数据集“SELECT_MATRIX_OPT”执行查询失败。 ---> System.Data.OracleClient.OracleException: ORA-12602: TNS: 达到连接共享限制