Thursday, December 30, 2010

Database ID 5, Page (1:4171728) is marked RestorePending, which may indicate disk corruption.

I recently encountered a power outage which drained our UPS backups and abnormally shut down my database server.
 

Once I brought it online again, when accessing certain records, I got this error message

Database ID 5, Page (1:4171728) is marked RestorePending, which may indicate disk corruption. To recover from this state, perform a restore.
 

I tried to do a page restore, and it completed successfully, but the problem still existed.
 
Running the  DBCC CHECKDB statement, it showed that I still had errors in the database.
 

To resolve this, I put the database in Emergency mode and set it to single user. I then did a repair_allow_data_loss to repair the bad portions of the database.
 

Remember to kill any connections to the database except your own in order to set the database to single user. 
 

See scripts below...
 

Script 
USE master
RESTORE DATABASE myDB
PAGE = '1:4171728'FROM DISK = 'D:\Backups\Database\myDB Full'WITH NORECOVERY; 

Result
Processed 1 pages for database 'myDB', file 'myDB' on file 1.RESTORE DATABASE ... FILE=<name> successfully processed 1 pages in 4229.373 seconds (0.000 MB/sec).  

Script
DBCC CHECKDB (myDB, repair_allow_data_loss) WITH NO_INFOMSGS; 

Result
Msg 8928, Level 16, State 1, Line 1Object ID 821577965, index ID 1, partition ID 72057594081050624, alloc unit ID 72057594085769216 (type In-row data): Page (1:4171728) could not be processed.  See other errors for details.Msg 8939, Level 16, State 98, Line 1Table error: Object ID 821577965, index ID 1, partition ID 72057594081050624, alloc unit ID 72057594085769216 (type In-row data), page (1:4171728). Test (IS_OFF (BUF_IOERR, pBUF->bstat)) failed. Values are 79825161 and -6.CHECKDB found 0 allocation errors and 2 consistency errors in table 'myTable' (object ID 821577965).CHECKDB found 0 allocation errors and 2 consistency errors in database 'myDB'.repair_allow_data_loss is the minimum repair level for the errors found by DBCC CHECKDB (myDB). 

Script
ALTER DATABASE myDB SET EMERGENCY; 

Script
ALTER DATABASE myDB SET SINGLE_USER WITH NO_WAIT; 

Script
DBCC CHECKDB (myDB, repair_allow_data_loss) WITH NO_INFOMSGS; 

Result
Repair: The Clustered index successfully rebuilt for the object "dbo.POAllocation" in database "myDB".Repair: The page (1:4171728) has been deallocated from object ID 821577965, index ID 1, partition ID 72057594081050624, alloc unit ID 72057594085769216 (type In-row data).Repair: The Nonclustered index successfully rebuilt for the object "dbo.myTable, PK_myTable" in database "myDB".Repair: The Nonclustered index successfully rebuilt for the object "dbo.myTable, IDX_myTable_myColumn" in database "myDB".Msg 8945, Level 16, State 1, Line 1Table error: Object ID 821577965, index ID 1 will be rebuilt.        The error has been repaired.Msg 8928, Level 16, State 1, Line 1Object ID 821577965, index ID 1, partition ID 72057594081050624, alloc unit ID 72057594085769216 (type In-row data): Page (1:4171728) could not be processed.  See other errors for details.        The error has been repaired.Msg 8939, Level 16, State 98, Line 1Table error: Object ID 821577965, index ID 1, partition ID 72057594081050624, alloc unit ID 72057594085769216 (type In-row data), page (1:4171728). Test (IS_OFF (BUF_IOERR, pBUF->bstat)) failed. Values are 62916617 and -6.        The error has been repaired.Msg 8976, Level 16, State 1, Line 1Table error: Object ID 821577965, index ID 1, partition ID 72057594081050624, alloc unit ID 72057594085769216 (type In-row data). Page (1:4171728) was not seen in the scan although its parent (1:567168) and previous (1:4100112) refer to it. Check any previous errors.        The error has been repaired.Msg 8978, Level 16, State 1, Line 1Table error: Object ID 821577965, index ID 1, partition ID 72057594081050624, alloc unit ID 72057594085769216 (type In-row data). Page (1:4171730) is missing a reference from previous page (1:4171728). Possible chain linkage problem.        The error has been repaired.Msg 8945, Level 16, State 1, Line 1Table error: Object ID 821577965, index ID 2 will be rebuilt.        The error has been repaired.Msg 8945, Level 16, State 1, Line 1Table error: Object ID 821577965, index ID 3 will be rebuilt.        The error has been repaired.CHECKDB found 0 allocation errors and 4 consistency errors in table 'myTable' (object ID 821577965).CHECKDB fixed 0 allocation errors and 4 consistency errors in table 'myTable' (object ID 821577965).CHECKDB found 0 allocation errors and 4 consistency errors in database 'myDB'.CHECKDB fixed 0 allocation errors and 4 consistency errors in database 'myDB'. 

Script
ALTER DATABASE myDB SET MULTI_USER WITH NO_WAIT; 

Script
ALTER DATABASE myDB SET ONLINE; 

1 comment: