SQL Server Storage Engine

Which part of 'REPAIR_ALLOW_DATA_LOSS' isn't clear?

In my chalk/talk at TechEd yesterday, I asked the crowd "what's the purpose of repair?" One person got it right. The purpose is not to save data. Surprised? The purpose is to get the database back to a structurally and transactionally consistent state so that processing can safely continue.

We chose the name of this repair option very carefully and it's pretty obvious what you're implying when you use it - "please fix up my database and if you have to delete some data to do that then - ok".

When CHECKDB reports that the recommended repair option is REPAIR_ALLOW_DATA_LOSS, that's because it's going to have to delete something to repair the damaged database. We're not talking about damaged non-clustered indexes here, we're talking about heap or clustered index data records or pages being deleted.

For instance, if a data record has a text column, but we can't find the matching off-row text storage, then the record is deleted because it doesn't contain a valid table row. If that row represents a customer account (for instance a bank account as described in the previous post), you've got one annoyed customer on your hands. However, if the data record has a corrupt structure, such that the variable-length offset array pointer is pointing off beyond the end of the record, then we can't trust anything on the page and we have to delete the entire thing. Depending on your fanout, that could mean deleting 300 data records or more! That means you'll be dealing with more than 300 annoyed customers, who may tell their friends, and so on - pretty soon your bank is bankrupt and you're on the street destitute! Well, maybe I got a bit carried away there but you get the idea - data loss is not good for your business.

But wait, some may say, surely there's some good that can come of running repair? Actually, no - there's just more badness. Repair is just trying to get the physical structures fixed up - it pays no attention to higher-level logical structures. This means that, for instance, foreign-key constraints may be broken along with any inherent business logic in your database.

So, given all the nasty things that can happen when you run repair - make it your absolute last choice, not your first choice - always have a good backup strategy.

Next time - how we took the worst two things you can do to your database (rebuilding the transaction log and running REPAIR_ALLOW_DATA_LOSS) and made them into a cool new feature in SQL Server 2005.

(Btw, if you're ever in Boston, the sushi bar in the Boston Mariott Copley Place does fantastic sashimi, and Sam Adams is almost as good as Mac & Jacks - guess what I had for dinner tonight...)

Published Friday, June 16, 2006 2:57 AM by Paul Randal - MSFT
Filed under: ,

Comments

 

MikeWalsh said:

Ahhhh I always though allow_data_loss always meant that no data loss occurs, but actually a full backup automatically happens and the data is magically repaired to it's pristine state with no manual intervention. I think I read that on a website somehwere or something. It had something about the best way to delete some extra file that wasn't needed... I think it was an LDF or something?? ;^)    seriously though, keep up the good posts. hopefully some of these entries will get linked enough to land on google above the "dangerous advice with no warning" websites out there.
June 16, 2006 10:42 PM
 

SQL Server Storage Engine said:

Emergency mode repair? In a couple of previous posts I explained how the two worst things you could do...
June 18, 2006 11:15 AM
 

SQL Server Storage Engine said:

I was teaching at a Microsoft-internal class last week and there was a discussion on what corruptions

February 7, 2007 4:54 PM
 

SQL Server Storage Engine Which part of REPAIR ALLOW DATA LOSS | Outdoor Ceiling Fans said:

May 31, 2009 9:14 AM
 

SQL Server Storage Engine Which part of REPAIR ALLOW DATA LOSS | Outdoor Decor said:

June 13, 2009 6:19 PM
 

SQL Server Storage Engine Which part of REPAIR ALLOW DATA LOSS | patio set said:

June 17, 2009 10:02 PM
 

SQL Server Storage Engine Which part of REPAIR ALLOW DATA LOSS | home lighting said:

June 19, 2009 1:46 AM
 

SQL Server Storage Engine Which part of REPAIR ALLOW DATA LOSS | patio cushions said:

June 19, 2009 6:06 AM
Anonymous comments are disabled

About Paul Randal - MSFT

Paul started in the industry in 1994 working for DEC on the VMS file system and check/repair tools. In 1999 he moved to Microsoft to work on SQL Server, specifically on DBCC. For SQL Server 2000, he concentrated on index fragmentation (writing DBCC INDEXDEFRAG and DBCC SHOWCONTIG) plus various algorithms in DBCC CHECKDB. During SQL Server 2005 development Paul was the lead developer/manager of one the core dev teams in the Storage Engine, responsible for data access and storage (DBCC, allocation, indexes & heaps, pages/records, text/LOB storage, snapshot isolation, etc). He also spent several years rewriting DBCC CHECKDB and repair. For SQL Server 2008, Paul managed the Program Management team for the core Storage Engine to become more focused on customer/partner engagement and feature set definition. In 2007, after 8.5 years on the SQL Server team, Paul left Microsoft to join his wife, Kimberly Tripp, running SQLskills.com and pursuing his passion for presenting and consulting. Paul regularly presents at conferences and user groups around the world on high-availability, disaster recovery and Storage Engine internals. His popular blog is at http://www.sqlskills.com/blogs/paul/.

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker