{"id":858,"date":"2009-05-15T17:02:00","date_gmt":"2009-05-15T17:02:00","guid":{"rendered":"\/blogs\/paul\/post\/Misconceptions-around-database-repair.aspx"},"modified":"2013-01-01T19:43:51","modified_gmt":"2013-01-02T03:43:51","slug":"misconceptions-around-database-repair","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/paul\/misconceptions-around-database-repair\/","title":{"rendered":"Misconceptions around database repair"},"content":{"rendered":"<p>\n<font face=\"verdana,geneva\" size=\"2\">This week&#39;s been a busy one on the forums and Twitter, with lots of interesting problems people are hitting. One of the things I&#39;ve noticed is that there are lot&#39;s of misconceptions about running repair, so to round out Friday I&#39;m going to run through a list of them for you. Here are the misconceptions, some of which I&#39;ve had to argue several times with people and eventually resort to &#39;Look, I wrote the repair code, I&#39;m sorry but you&#39;re wrong&#39;, which I hate&nbsp;doing: <\/font>\n<\/p>\n<ul>\n<li>\n<div>\n\t<font face=\"verdana,geneva\" size=\"2\"><strong>Repair will not cause data loss<\/strong>. It depends. If you have to use REPAIR_ALLOW_DATA_LOSS, then you&#39;re going to lose data. That&#39;s why the option is named that &#8211; seriously.<\/font>\n\t<\/div>\n<\/li>\n<li>\n<div>\n\t<font face=\"verdana,geneva\" size=\"2\"><strong>Repair should be run as the default<\/strong>. No. Figure out what&#39;s wrong first before deciding what to do about it. If you&#39;ve got a damaged 1TB clustered index, it&#39;s going to get rebuilt by repair. If you don&#39;t have an extra 1TB of disk space, it will fail, and then you&#39;re back to square one after hours of fruitless effort. You might be able to get away with doing something that doesn&#39;t involve taking the database (essentially) offline.<\/font>\n\t<\/div>\n<\/li>\n<li>\n<div>\n\t<font face=\"verdana,geneva\" size=\"2\"><strong>You can run repair without running DBCC CHECKDB<\/strong>. No. Repair is an option to one of the&nbsp;consistency-checking commands (DBCC CHECKALLOC, DBCC CHECKTABLE, or DBCC CHECKDB &#8211; note that DBCC CHECKFILEGROUP and DBCC CHECKCATALOG&nbsp;don&#39;t support repair).<\/font>\n\t<\/div>\n<\/li>\n<li>\n<div>\n\t<font face=\"verdana,geneva\" size=\"2\"><strong>As soon as you&#39;ve run repair, everything&#39;s fine<\/strong>. No. You should always run DBCC CHECKDB a second time after running repair, to make sure the first repair fixed everything. Sometimes a corruption prevents some deeper checks being done, and when it&#39;s fixed, the next DBCC CHECKDB can run the deeper check and find more corruptions. I call this &#39;corruption masking&#39;. The other reason is that repair probably just deleted some of your data. What effect is that going to have on the application? What if that&#39;s medical patient data? Or insurance records? Or back account details?<\/font>\n\t<\/div>\n<\/li>\n<li>\n<div>\n\t<font face=\"verdana,geneva\" size=\"2\"><strong>Repair can always fix everything<\/strong>.&nbsp;No. There are some things that DBCC CHECKDB cannot fix. See <\/font><a href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/checkdb-from-every-angle-can-checkdb-repair-everything\/\"><font face=\"verdana,geneva\" size=\"2\">CHECKDB From Every Angle: Can CHECKDB repair everything?<\/font><\/a><font face=\"verdana,geneva\" size=\"2\">&nbsp;for the list.<\/font>\n\t<\/div>\n<\/li>\n<li>\n<div>\n\t<font face=\"verdana,geneva\" size=\"2\"><strong>Repair is safe to use on system databases<\/strong>. No. It cannot be used on master or tempdb because they cannot be put into single-user mode. You can do it on model, but it&#39;s unlikely to have an effect as there aren&#39;t any user tables in model (unless you create them) and system tables generally don&#39;t get repaired. You can run it on msdb, but it might have strange side-effects. See <\/font><a href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/is-running-repair-on-msdb-safe\/\"><font face=\"verdana,geneva\" size=\"2\">Is running repair on msdb safe?<\/font><\/a><font face=\"verdana,geneva\" size=\"2\">.<\/font>\n\t<\/div>\n<\/li>\n<li>\n<div>\n\t<font face=\"verdana,geneva\" size=\"2\"><strong>You can run repairs online<\/strong>. No. Repairs are always offline, in that the database must be in single-user mode.<\/font>\n\t<\/div>\n<\/li>\n<li>\n<div>\n\t<font face=\"verdana,geneva\" size=\"2\"><strong>REPAIR_REBUILD will fix everything<\/strong>. No. REPAIR_REBUILD only fixes problem in nonclustered indexes. In 2005 onwards, REPAIR_FAST does nothing at all.<\/font>\n\t<\/div>\n<\/li>\n<li>\n<div>\n\t<font face=\"verdana,geneva\" size=\"2\"><strong>Repairs on a repl Publisher propagate to the Subscribers<\/strong>. No. Anything done by repair is NOT marked for replication. You must reinitialize your Subscribers if you repair a Publisher.<\/font>\n\t<\/div>\n<\/li>\n<li>\n<div>\n\t<font face=\"verdana,geneva\" size=\"2\"><strong>Repairs always fix-up constraints<\/strong>. No. It has no idea that constraints exist. After repairing a database with constraints, you should run DBCC CHECKCONSTRAINT to make sure they&#39;re still valid.<\/font>\n\t<\/div>\n<\/li>\n<li>\n<div>\n\t<font face=\"verdana,geneva\" size=\"2\"><strong>Repairs try to save data<\/strong>. No. It doesn&#39;t go out of it&#39;s way to delete data, but it doesn&#39;t go out of it&#39;s way to save data in most cases. &#39;Delete what&#39;s broken and fix up all the links&#39; is my sound-bite explanation of what repair does. Fix things as fast as possible and as provably correct as possible.<\/font>\n\t<\/div>\n<\/li>\n<li>\n<div>\n\t<font face=\"verdana,geneva\" size=\"2\"><strong>EMERGENCY mode repair will always work<\/strong>. No. I&#39;ve seen cases where something broken in the file-system caused&nbsp;it to fail. Don&#39;t rely on repair.<\/font>\n\t<\/div>\n<\/li>\n<li>\n<div>\n\t<font size=\"2\"><strong>You can undo repairs<\/strong>. It depends. If you started an explicit transaction, then you can roll everything back if you don&#39;t like what it did. People rarely do this though. EMERGENCY mode repair can never be rolled back.<\/font>\n\t<\/div>\n<\/li>\n<\/ul>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">Repair&#39;s a dangerous beast and should only be used as a last resort, or to bring a VVVLDB online again potentially much faster than a full restore, when a small amount of data loss can be tolerated. This is just a quick brain-dump of things people get wrong about repair.<\/font>\n<\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">Have a great weekend &#8211; tomrorow I&#39;ll report on last week&#39;s survey and kick off a new one. Cheers! <\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This week&#39;s been a busy one on the forums and Twitter, with lots of interesting problems people are hitting. One of the things I&#39;ve noticed is that there are lot&#39;s of misconceptions about running repair, so to round out Friday I&#39;m going to run through a list of them for you. Here are the misconceptions, [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,22,30,34,35,61,74],"tags":[],"class_list":["post-858","post","type-post","status-publish","format-standard","hentry","category-bad-advice","category-checkdb-from-every-angle","category-corruption","category-dbcc","category-disaster-recovery","category-misconceptions","category-repair"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Misconceptions around database repair - Paul S. Randal<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/misconceptions-around-database-repair\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Misconceptions around database repair - Paul S. Randal\" \/>\n<meta property=\"og:description\" content=\"This week&#039;s been a busy one on the forums and Twitter, with lots of interesting problems people are hitting. One of the things I&#039;ve noticed is that there are lot&#039;s of misconceptions about running repair, so to round out Friday I&#039;m going to run through a list of them for you. Here are the misconceptions, [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/paul\/misconceptions-around-database-repair\/\" \/>\n<meta property=\"og:site_name\" content=\"Paul S. Randal\" \/>\n<meta property=\"article:published_time\" content=\"2009-05-15T17:02:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-01-02T03:43:51+00:00\" \/>\n<meta name=\"author\" content=\"Paul Randal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Paul Randal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/misconceptions-around-database-repair\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/misconceptions-around-database-repair\/\",\"name\":\"Misconceptions around database repair - Paul S. Randal\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\"},\"datePublished\":\"2009-05-15T17:02:00+00:00\",\"dateModified\":\"2013-01-02T03:43:51+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/misconceptions-around-database-repair\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/paul\/misconceptions-around-database-repair\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/misconceptions-around-database-repair\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Misconceptions around database repair\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\",\"name\":\"Paul S. Randal\",\"description\":\"In Recovery...\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\",\"name\":\"Paul Randal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g\",\"caption\":\"Paul Randal\"},\"sameAs\":[\"http:\/\/3.209.169.194\/blogs\/paul\"],\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/author\/paul\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Misconceptions around database repair - Paul S. Randal","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqlskills.com\/blogs\/paul\/misconceptions-around-database-repair\/","og_locale":"en_US","og_type":"article","og_title":"Misconceptions around database repair - Paul S. Randal","og_description":"This week&#39;s been a busy one on the forums and Twitter, with lots of interesting problems people are hitting. One of the things I&#39;ve noticed is that there are lot&#39;s of misconceptions about running repair, so to round out Friday I&#39;m going to run through a list of them for you. Here are the misconceptions, [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/paul\/misconceptions-around-database-repair\/","og_site_name":"Paul S. Randal","article_published_time":"2009-05-15T17:02:00+00:00","article_modified_time":"2013-01-02T03:43:51+00:00","author":"Paul Randal","twitter_misc":{"Written by":"Paul Randal","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/misconceptions-around-database-repair\/","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/misconceptions-around-database-repair\/","name":"Misconceptions around database repair - Paul S. Randal","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website"},"datePublished":"2009-05-15T17:02:00+00:00","dateModified":"2013-01-02T03:43:51+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/misconceptions-around-database-repair\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/paul\/misconceptions-around-database-repair\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/misconceptions-around-database-repair\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/paul\/"},{"@type":"ListItem","position":2,"name":"Misconceptions around database repair"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/","name":"Paul S. Randal","description":"In Recovery...","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlskills.com\/blogs\/paul\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce","name":"Paul Randal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/0b6a266bba2f088f2551ef529293001bd73bf026bc1908b9866728c062beeeb6?s=96&d=mm&r=g","caption":"Paul Randal"},"sameAs":["http:\/\/3.209.169.194\/blogs\/paul"],"url":"https:\/\/www.sqlskills.com\/blogs\/paul\/author\/paul\/"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/858","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/comments?post=858"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/858\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/media?parent=858"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/categories?post=858"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/tags?post=858"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}