系统断定检查已失败。有关详细信息,请查看 SQL Server 错误日志
【1】报错信息
【1.1】运行增删查改时报错
我这里是运行删除操作的时候报的错
操作的删除语句:
IF OBJECT_ID('tempdb..#temp_Robot') IS NOT NULL DROP TABLE #temp_Robot CREATE TABLE #temp_Robot(UserID INT NOT NULL PRIMARY KEY) select * from #temp_robot INSERT INTO #temp_Robot SELECT UserID FROM Db_Tank..Sys_Users_Order WHERE IsRobot IN (1,3) DELETE FROM #temp_Robot WHERE UserID IN (SELECT UserID FROM Db_Tank..Sys_Users_Detail WHERE ConsortiaID>0)
--核心语句在这里 DELETE Db_Tank..Sys_Users_History WHERE UserID IN (SELECT UserID FROM #temp_Robot)
报错信息:
Location: lckmgr.cpp:9421 Expression: NULL == m_lockList.Head () SPID: 56 Process ID: 5972 Location: "xact.cpp":2630 Expression: !m_updNestedXactCnt SPID: 56 Process ID: 5972 Description: Trying to use the transaction while there are 1 parallel nested xacts outstanding Location: "xact.cpp":2788 Expression: !m_updNestedXactCnt SPID: 56 Process ID: 5972 Description: Trying to use the transaction while there are 1 parallel nested xacts outstanding Location: "xact.cpp":3851 Expression: !m_parNestedXactCnt SPID: 56 Process ID: 5972 Description: Trying to use the transaction while there are 7 parallel nested xacts outstanding Location: "xact.cpp":2879 Expression: !m_updNestedXactCnt SPID: 56 Process ID: 5972 Description: Trying to use the transaction while there are 1 parallel nested xacts outstanding 消息 3624,级别 20,状态 1,第 1 行 系统断定检查已失败。有关详细信息,请查看 SQL Server 错误日志 消息 0,级别 20,状态 0,第 0 行 当前命令发生了严重错误。应放弃任何可能产生的结果。
系统日志报错:
【1.2】运行还原时报错
90%是备份文件出了问题,另外可能是原主数据库本身就有问题,那备份文件自然就有问题了。
具体参考我另一篇文章:
https://www.cnblogs.com/gered/p/12174111.html
【2】排查办法
一般情况下,这种都是SQL中使用的条件中的相关列所在的索引出了问题
(1)使用select count(1) from Db_Tank..Sys_Users_History
发现也是卡顿,连查询都不能查,明显有问题啊。count(1) 探索的是聚集索引列
(2)查看表结构 sp_help Sys_Users_History
只有一个userid的聚集索引,正好我们删除也是用它来关联的。估计问题就出在这里了。
当然,这只是经验之谈,如果没什么经验的朋友建议运行DBCC CHECKDB('db_name') 检查一下这个库。
【3】解决办法,重建索引
use db_tank go alter index PK_Sys_Users_History on Sys_Users_History rebuild
OK,搞定!
【4】总结
出了问题不要慌,要想办法定位原因,然后得以解决