Thursday, January 15, 2009

SQL Server data corruption - DBCC checkdb ( REPAIR_ALLOW_DATA_LOSS )

Recently one of our sql server has a RAID 5 hard disk failure, after the hard disk is changed the sql server report data error while running the dbcc checkdb.

If the DBCC checkdb , returns error such as below, that means that the clustered index (index ID 0) could have been corrupted and data loss is a possiblities.

Server: Msg 8928, Level 16, State 1, Line 1Object ID 1335232803, index ID 0: Page (1:14469854) could not be processed. See other errors for details.
Server: Msg 8939, Level 16, State 1, Line 1Table error: Object ID 1335232803, index ID 0, page (1:14469854). Test (IS_ON (BUF_IOERR, bp->bstat) && bp->berrcode) failed. Values are 2057 and -1.
Server: Msg 8928, Level 16, State 1, Line 1Object ID 1335232803, index ID 0: Page (1:14469855) could not be processed. See other errors for details.Server: Msg 8928, Level 16, State 1, Line 1

If the Index ID is more than 1 , then only the index is spoilt.

After determining, the Page id we can get the raw data by using the below command. The 3 that's means formatted data and the 2 is the raw data.

DBCC TRACEON (3604);
GO
DBCC PAGE ('DB', 1, 14469854, 3);
GO

After this, we can find out the primary key of the tables . Based on this we can restored the data from the backup to here.

Another way is to restore the page data, this is only can be done minimumly in sql 2005

Links :-
SQL Server in Recovery by Paul S. Randal.
http://www.sqlskills.com/BLOGS/PAUL/category/Corruption.aspx#p31

Fixing damaged pages using page restore or manual inserts
http://blogs.msdn.com/sqlserverstorageengine/archive/2007/01/18/fixing-damaged-pages-using-page-restore-or-manual-inserts.aspx

No comments: