{"id":895,"date":"2011-02-14T16:00:00","date_gmt":"2011-02-14T14:00:00","guid":{"rendered":"https:\/\/www.sqlinthewild.co.za\/?p=895"},"modified":"2011-02-14T22:05:17","modified_gmt":"2011-02-14T20:05:17","slug":"quest-webcast-dos-and-donts-of-database-corruption","status":"publish","type":"post","link":"https:\/\/www.sqlinthewild.co.za\/index.php\/2011\/02\/14\/quest-webcast-dos-and-donts-of-database-corruption\/","title":{"rendered":"Quest Webcast: Dos and Don&#8217;ts of Database corruption"},"content":{"rendered":"<p>I was guest presenter on last week&#8217;s <a href=\"http:\/\/www.quest.com\/events\/ListDetails.aspx?ContentID=13506\">Quest Pain of the Week presentation. <\/a> The presentation is available for download from Quest. This is a roundup of the questions from the presentation. (I have edited some of the questions for spelling, grammar and readability)<\/p>\n<p><span style=\"color: #bd934f;\">Q: Why do you have to wait for a maintenance window to take a backup? you can backup during the time the database is being used.<\/span><\/p>\n<p>You don&#8217;t have to wait, and with a 24&#215;7 system you obviously can&#8217;t. But full backups do have an impact even though database can be in use at the time. They&#8217;re IO intensive. If you&#8217;re going to do backups while the system is in use, make sure that the additional IO load doesn&#8217;t adversely effect user performance, or look into things like SAN-level snapshot backups.<\/p>\n<p><span style=\"color: #bd934f;\">Q: If you partition your data, can you only backup the latest partition?<\/span><\/p>\n<p>Yes, however be mindful of the requirements for restoring from file\/filegroup backups. In full or bulk-logged recovery if the older filegroups are not read-only, you&#8217;ll need log backups covering the entire span from the oldest of the file\/filegroup backups you use to the newest.<\/p>\n<p>If the partitions with older data are read-only, then this is very easy to do.<\/p>\n<p>For more information see <a title=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms177425.aspx\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms177425.aspx\">http:\/\/msdn.microsoft.com\/en-us\/library\/ms177425.aspx<\/a><\/p>\n<p><span style=\"color: #bd934f;\">Q: What if you inherit a database that fails the integrity check every day and the backups have the same issue so you don&#8217;t know when the integrity check originally failed?<\/span><\/p>\n<p>That just means that restore from backup (full, file\/filegroup or page) is not an option for fixing. Probably means that there will be no avoiding data loss.<\/p>\n<p><span style=\"color: #bd934f;\">Q: The 825 errors &#8211; these are reported in the logs too aren&#8217;t they? I can review to see if these are occurring, even if the alert is not set?<\/span><\/p>\n<p>Yes they are (and I don&#8217;t know why I thought during the presentation that they aren&#8217;t, I&#8217;ve written a blog post on them myself). <a title=\"https:\/\/www.sqlinthewild.co.za\/index.php\/2008\/12\/06\/when-is-a-critical-io-error-not-a-critical-io-error\/\" href=\"https:\/\/www.sqlinthewild.co.za\/index.php\/2008\/12\/06\/when-is-a-critical-io-error-not-a-critical-io-error\/\">https:\/\/www.sqlinthewild.co.za\/index.php\/2008\/12\/06\/when-is-a-critical-io-error-not-a-critical-io-error\/<\/a><\/p>\n<blockquote><p>Msg 825, Level 10, State 2, Line 1.<br \/>\nA read of the file \u2018D:\\Data\\SomeDB.mdf\u2019 at offset 0x00000020e24000  succeeded after failing 1 time(s) with error: incorrect checksum  (expected: 0x7532c420; actual: 0x320e4240). Additional messages in the  SQL Server error log and system event log may provide more detail. This  error condition threatens database integrity and must be corrected.  Complete a full database consistency check (DBCC CHECKDB). This error  can be caused by many factors; for more information, see SQL Server  Books Online.<\/p><\/blockquote>\n<p><span style=\"color: #bd934f;\">Q: Can you use Resource Governor for a large DB backup to keep the DB&#8217;s performance at an acceptable level?<\/span><\/p>\n<p>Resource governor only limits CPU and memory, not IO.<\/p>\n<p><span style=\"color: #bd934f;\">Q: If you have data loss, shouldn&#8217;t you be doing a restore?<\/span><\/p>\n<p>Maybe. It could be (due to time to restore or other constraints) that the fastest and acceptable solution is to repair (CheckTable or CheckFileGroup) and then sync in missing data later.<\/p>\n<p><span style=\"color: #bd934f;\">Q: I just had this happen on an archive database that I can play with. The problem occurred with lob&#8217;s. Since allow data loss removes the entire page that the corruption is on how does this work with lob&#8217;s that are not stored on the same page as the record?<\/span><\/p>\n<p>The entire LOB chain (all LOB pages for the row) will be deallocated and the data\/index record which is the parent will be deleted. (Ref: Chapter 11 of SQL Server 2008 Internals by Kalen Delaney et al. Chapter 11 written by Paul Randal)<\/p>\n<p><span style=\"color: #bd934f;\">Q: Is it possible to create a corrupted database in a test lab to get an 825 error?<\/span><\/p>\n<p>Error 825 is a hard one to generate. To get that you need for an IO to fail or the retrieved page to be damaged and then on a retry (which occurs immediately) for the IO to succeed and the page to be correct. That&#8217;s hard to fake. You&#8217;ll need an IO filter driver that is coded to intermittently mess up IOs.<\/p>\n<p>For 824, either use a hex editor to edit pages of a test database, or download and restore <a href=\"http:\/\/sqlskills.com\/BLOGS\/PAUL\/post\/Sample-corrupt-databases-to-play-with.aspx\">Paul Randal&#8217;s pre-corrupted databases<\/a>.<\/p>\n<p>For 823, create a database with a secondary file on a flash drive. Create a large table in the filegroup on the flash drive, checkpoint, DBCC dropcleanbuffers, then pull the flash drive out and query the table. If that doesn&#8217;t throw the error (meaning the pages are still in memory), update a row and checkpoint.<\/p>\n<p>It goes without saying that neither of these should ever be done on a server!<\/p>\n<p><span style=\"color: #bd934f;\">Q: In case of db suspect (not recoverable) can we update the system table sysdatabases and change the status to make it online (this solution used to work in SQL 2000)<\/span><\/p>\n<p>That is a SQL 2000 solution. In SQL 2005 and above, sysdatabases isn&#8217;t a table and the system tables cannot be updated as was possible in SQL 2000.<\/p>\n<p>Fortunately there&#8217;s a fully documented and supported alternative \u2013 ALTER DATABASE &lt;Database name&gt; SET EMERGENCY. Once in emergency mode you can run CheckDB with repair_allow_data_loss and then bring the database online (assuming the repair succeeds), or extract data if the repair fails.<\/p>\n<p><span style=\"color: #bd934f;\">Q: Is Check DB the only tool available?<\/span><\/p>\n<p>To check database integrity, yes.<\/p>\n<p><span style=\"color: #bd934f;\">Q: If you got a foreign key, you can restore a table but will integrity not be broken?<\/span><\/p>\n<p>Relational and possibly transactional integrity may be broken. I&#8217;d guess that&#8217;s one reason table-level restores aren&#8217;t available natively in the product.<\/p>\n<p><span style=\"color: #bd934f;\">Q: Checksum on database backup &#8211; this is not an option in maintenance plan &#8211; true? To enable this, I have to script all database backups?<\/span><\/p>\n<p>Correct, it&#8217;s not an option on maintenance plans. Personally I&#8217;m not a fan of maintenance plans for anything other than trivial environments.<\/p>\n<p><span style=\"color: #bd934f;\">Q: We use some SQL Express, do all these items work in Express? I had one that the hard drive died and I was able to get it back from suspect at which point I did a full backup and restored it elsewhere on a full SQL Server to fix it<\/span><\/p>\n<p>The only limitation for CheckDB on Express is no parallelism.<\/p>\n<p>File\/filegroup restores can be done on Express, though they are offline restores.<\/p>\n<p>Page restores can be done on Express, though they are offline restores<\/p>\n<hr \/>\n<p>Thanks to Paul Randal and Robert Davis for assistance with a couple of these answers.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was guest presenter on last week&#8217;s Quest Pain of the Week presentation. The presentation is available for download from Quest. This is a roundup of the questions from the presentation. (I have edited some of the questions for spelling,&#8230; <a class=\"read-more-button\" href=\"https:\/\/www.sqlinthewild.co.za\/index.php\/2011\/02\/14\/quest-webcast-dos-and-donts-of-database-corruption\/\">(Read more)<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[22,15,16],"tags":[],"class_list":["post-895","post","type-post","status-publish","format-standard","hentry","category-corruption","category-sql-server","category-syndication"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p7h6n-er","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.sqlinthewild.co.za\/index.php\/wp-json\/wp\/v2\/posts\/895","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlinthewild.co.za\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlinthewild.co.za\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlinthewild.co.za\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlinthewild.co.za\/index.php\/wp-json\/wp\/v2\/comments?post=895"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlinthewild.co.za\/index.php\/wp-json\/wp\/v2\/posts\/895\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlinthewild.co.za\/index.php\/wp-json\/wp\/v2\/media?parent=895"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlinthewild.co.za\/index.php\/wp-json\/wp\/v2\/categories?post=895"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlinthewild.co.za\/index.php\/wp-json\/wp\/v2\/tags?post=895"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}