如何排查SQL Server Agent作业中SSAS表格模型刷新失败的具体表错误
当前问题场景
我们通过SQL Server Agent作业调用SSAS命令每日刷新表格模型Cube,执行的命令如下:
{ "refresh": { "type": "full", "objects": [ { "database": "KPIDashboardv1" } ] } }
作业失败时仅返回笼统错误,无法定位具体导致失败的表,现寻求获取包含具体表名的详细错误信息的方法。
当前SQL Agent作业返回的错误信息
Microsoft.AnalysisServices.Xmla.XmlaException: 当前操作已取消,因为事务中的另一操作失败。
在 Microsoft.AnalysisServices.Xmla.XmlaClient.CheckForSoapFault(XmlReader reader, XmlaResult xmlaResult, Boolean throwIfError)
在 Microsoft.AnalysisServices.Xmla.XmlaClient.CheckForError(XmlReader reader, XmlaResult xmlaResult, Boolean throwIfError)
在 Microsoft.AnalysisServices.Xmla.XmlaClient.SendMessage(Boolean endReceivalIfException, Boolean readSession, Boolean readNamespaceCompatibility)
在 Microsoft.AnalysisServices.Xmla.XmlaClient.SendMessageAndReturnResult(String& result, Boolean skipResult)
在 Microsoft.AnalysisServices.Xmla.XmlaClient.ExecuteStatement(String statement, String properties, String& result, Boolean skipResult, Boolean propertiesXmlIsComplete)
在 Microsoft.AnalysisServices.Xmla.XmlaClient.Execute(String command, String properties, String& result, Boolean skipResult, Boolean propertiesXmlIsComplete)
在 Microsoft.SqlServer.Management.Smo.Olap.SoapClient.ExecuteStatement(String stmt, StatementType stmtType, Boolean withResults, String properties, String parameters, Boolean restrictionListElement, String discoverType, String catalog)
在 Microsoft.SqlServer.Management.Smo.Olap.SoapClient.SendCommand(String command, Boolean withResults, String properties)
在 OlapEvent(SCH_STEP* pStep, SUBSYSTEM* pSubSystem, SUBSYSTEMPARAMS* pSubSystemParams, Boolean fQueryFlag)Microsoft.AnalysisServices.Xmla.XmlaException: OLE DB 或 ODBC 错误: 查询超时已过期;HYT00;从 SQL Server 收到未知令牌;HY000。
在 Microsoft.AnalysisServices.Xmla.XmlaClient.CheckForSoapFault(XmlReader reader, XmlaResult xmlaResult, Boolean throwIfError)
在 Microsoft.AnalysisServices.Xmla.XmlaClient.CheckForError(XmlReader reader, XmlaResult xmlaResult, Boolean throwIfError)
在 Microsoft.AnalysisServices.Xmla.XmlaClient.SendMessage(Boolean endReceivalIfException, Boolean readSession, Boolean readNamespaceCompatibility)
在 Microsoft.AnalysisServices.Xmla.XmlaClient.SendMessageAndReturnResult(String& result, Boolean skipResult)
在 Microsoft.AnalysisServices.Xmla.XmlaClient.ExecuteStatement(String statement, String properties, String& result, Boolean skipResult, Boolean propertiesXmlIsComplete)
在 Microsoft.AnalysisServices.Xmla.XmlaClient.Execute(String command, String properties, String& result, Boolean skipResult, Boolean propertiesXmlIsComplete)
在 Microsoft.SqlServer.Management.Smo.Olap.SoapClient.ExecuteStatement(String stmt, StatementType stmtType, Boolean withResults, String properties, String parameters, Boolean restrictionListElement, String discoverType, String catalog)
在 Microsoft.SqlServer.Management.Smo.Olap.SoapClient.SendCommand(String command, Boolean withResults, String properties)
在 OlapEvent(SCH_STEP* pStep, SUBSYSTEM* pSubSystem, SUBSYSTEMPARAMS* pSubSystemParams, Boolean fQueryFlag)Microsoft.AnalysisServices.Xmla.XmlaException: OLE DB 或 ODBC 错误: 查询超时已过期;HYT00;从 SQL Server 收到未知令牌;HY000。
在 Microsoft.AnalysisServices.Xmla.XmlaClient.CheckForSoapFault(XmlReader reader, XmlaResult xmlaResult, Boolean throwIfError)
在 Microsoft.AnalysisServices.Xmla.XmlaClient.CheckForError(XmlReader reader, XmlaResult xmlaResult, Boolean throwIfError)
在 Microsoft.AnalysisServices.Xmla.XmlaClient.SendMessage(Boolean endReceivalIfException, Boolean readSession, Boolean readNamespaceCompatibility)
在 Microsoft.AnalysisServices.Xmla.XmlaClient.SendMessageAndReturnResult(String& result, Boolean skipResult)
在 Microsoft.AnalysisServices.Xmla.XmlaClient.ExecuteStatement(String statement, String properties, String& result, Boolean skipResult, Boolean propertiesXmlIsComplete)
在 Microsoft.AnalysisServices.Xmla.XmlaClient.Execute(String command, String properties, String& result, Boolean skipResult, Boolean propertiesXmlIsComplete)
在 Microsoft.SqlServer.Management.Smo.Olap.SoapClient.ExecuteStatement(String stmt, StatementType stmtType, Boolean withResults, String properties, String parameters, Boolean restrictionListElement, String discoverType, String catalog)
在 Microsoft.SqlServer.Management.Smo.Olap.SoapClient.SendCommand(String command, Boolean withResults, String properties)
在 OlapEvent(SCH_STEP* pStep, SUBSYSTEM* pSubSystem, SUBSYSTEMPARAMS* pSubSystemParams, Boolean fQueryFlag)作业 'PKG_MIB_DLY'
获取详细错误信息的方法
方法1:修改SSAS刷新命令,添加错误详细记录参数
在刷新命令中加入ExtendedProperties配置,指定返回详细错误信息:
{ "refresh": { "type": "full", "objects": [{"database": "KPIDashboardv1"}], "ExtendedProperties": { "ErrorConfiguration": { "KeyErrorLimit": 0, "KeyErrorLogFile": "C:\\SSAS_Logs\\Refresh_Errors.log", "KeyErrorAction": "StopLogging" } } } }
该配置会将详细错误(含具体表名、错误原因)写入指定日志文件,需确保SSAS服务账户有日志目录的读写权限。
方法2:通过SSAS跟踪日志查看详细错误
- 打开SQL Server Management Studio,连接到SSAS实例。
- 右键实例 → 跟踪 → 启动新跟踪。
- 在跟踪事件选择中,勾选Errors and Warnings下的所有事件,以及Progress Reports下的Progress Report Begin、Progress Report End事件。
- 启动跟踪后执行刷新作业,跟踪日志会记录每个表的刷新状态,失败时会显示具体表名和错误详情。
方法3:拆分刷新操作,逐个刷新表
将原有的全库刷新命令拆分为逐个表的刷新命令,这样作业失败时就能直接定位到对应的表:
{ "refresh": { "type": "full", "objects": [ {"database": "KPIDashboardv1", "table": "表1"}, {"database": "KPIDashboardv1", "table": "表2"} // 依次添加所有需要刷新的表 ] } }
注意:此方法会增加作业执行时间,但能快速定位失败表。
方法4:查看SSAS服务器日志
SSAS默认日志目录一般为C:\Program Files\Microsoft SQL Server\MSAS15.MSSQLSERVER\OLAP\Log(版本不同路径可能有差异),日志文件中包含详细的刷新操作记录,失败时会明确标注出错的表和具体错误信息。
内容的提问来源于stack exchange,提问作者Jasper

