Environment: WinServer2008 SP2+SQL Server 2008
昨天檢查SQL Server的時候在記錄檔裡看見一整串長相不凡的訊息... 大概長這樣:
Using 'dbghelp.dll' version '4.0.5'
***Stack Dump being sent to D:\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\LOG\SQLDump0001.txt
... (略)
錯誤: 5243,嚴重性: 22,狀態: 8。
An inconsistency was detected during an internal operation. Please contact technical support.
最明顯的訊息大概就最後兩行了吧... 另外一個dump file內容更是人類無法閱讀= =,明顯是要給機器讀的。
先是找到這篇: M$技術支援, Article ID:828337: An assertion or Msg 7987 may occur when an operation is performed on an instance of SQL Server.
標題看起來不怎麼有關係,不過內容確實有一些蛛絲馬跡。最早在SQL Server2000執行SELECT或UPDATE之類的transact-SQL時,就可能會有3624的錯誤訊息,而同樣的錯誤在SQL Server2005, 2008則是錯誤5242或5243。
造成5242/5243錯誤的原因只有簡單一小行: The problem may occur if inconsistencies exist in the databases on the instance of SQL Server....
還好相當有良心的還有solution..
- On the instance of SQL Server where the failure occurred, run the DBCC CHECKDB Transact-SQL command on all the databases.
- If the DBCC CHECKDB Transact-SQL command reports errors that indicate database inconsistencies, resolve the errors.
哈哈哈(乾笑三聲)... 一點都沒有好人做到底,送佛送到西的精神XD,連CHECKDB都不認識請參閱這兒(2000)或這兒(2008)。
所以就找了時間針對SQL Server裡的每個資料庫跑了下面這串指令。
DBCC CHECKDB(‘DB_NAME’) WITH ALL_ERRORMSGS;
(如果資料庫真的相當龐大,建議加個PHYSICAL_ONLY選項..)
結果每個資料庫的檢查結果都正常@_@a.. 雖然是個好消息,不過還是滿令人錯愕的阿XD 資料庫不會平白無故地耍人吧OTZ,所以不死心又多看了幾篇文章,終於,Paul S. Randal先生(SQL Server MVP, 撰寫2005 DBCC CHECKDB的人,這篇文章最後有簡介)給了個比較讓人釋懷的說明。
基本上5242跟5243是一樣的錯誤,不過5242會明確指出資料庫的哪個地方出了問題,5243卻是不明原因,資料庫無法指出的錯誤所丟出來的。雖然記錄檔紀錄了相關的訊息,這中間有可能其他的維護作業重建了索引,currupt pages被釋放,所以事後跑checkdb就看不出有任何錯誤。
大致上就這樣囉~
Ref:
Know what to do when the Error 5243 arises in an MS SQL Server 2000 database. http://www.sqlrecoverysoftware.net/blog/sql-error-5242.html