{"id":916,"date":"2009-03-22T06:14:00","date_gmt":"2009-03-22T06:14:00","guid":{"rendered":"\/blogs\/paul\/post\/IAM-page-corruption-examples.aspx"},"modified":"2013-01-01T21:12:08","modified_gmt":"2013-01-02T05:12:08","slug":"iam-page-corruption-examples","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/paul\/iam-page-corruption-examples\/","title":{"rendered":"IAM page corruption examples"},"content":{"rendered":"<p>\n<font face=\"verdana,geneva\" size=\"2\">A thread cropped up on SQLServerCentral involving IAM chain corruption (see <\/font><a href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/inside-the-storage-engine-iam-pages-iam-chains-and-allocation-units\/\"><font face=\"verdana,geneva\" size=\"2\">Inside the Storage Engine: IAM pages, IAM chains, and allocation units<\/font><\/a><font face=\"verdana,geneva\" size=\"2\">&nbsp;for details of IAM chains). The error from DBCC CHECKDB was: <\/font>\n<\/p>\n<blockquote>\n<p>\n\t<font face=\"courier new,courier\" size=\"2\">Server: Msg 2576, Level 16, State 1, Line 1<br \/>\n\tIAM page (0:0) is pointed to by the previous pointer of IAM page (1:394336) object ID 229575856 index ID 4 but was not detected in the scan. <\/font>\n\t<\/p>\n<\/blockquote>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">and there was some discussion of what the error meant, and why the initial page ID in the error of (0:0) means something special. There was a further question of how the errors would differ if the IAM page header was partially zero&#39;d out by an I\/O subsystem error. <\/font>\n<\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">We&#39;re on-stage here at SQL Connections doing a pre-con and I&#39;m not on until this afternoon so I can bang out a quick blog post! I&#39;m going to create a small database and show the difference between the two cases. The error above was from a SQL 2000 database, but the behavior is the same on SQL 2005 and 2008. Here&#39;s the script to create the database. <\/font>\n<\/p>\n<blockquote>\n<p>\n\t<font face=\"courier new,courier\" size=\"2\">CREATE DATABASE CorruptIAMEXample;<br \/>\n\tGO<br \/>\n\tUSE CorruptIAMExample;<br \/>\n\tGO <\/font>\n\t<\/p>\n<p>\n\t<font face=\"courier new,courier\" size=\"2\">CREATE TABLE test (c1 INT IDENTITY, c2 CHAR (8000) DEFAULT &#39;a&#39;);<br \/>\n\tGO<br \/>\n\tCREATE CLUSTERED INDEX test_cl on test (c1);<br \/>\n\tGO <\/font>\n\t<\/p>\n<p>\n\t<font face=\"verdana,geneva\" size=\"2\"><font face=\"courier new,courier\">SET NOCOUNT ON;<br \/>\n\tGO<br \/>\n\tINSERT INTO test DEFAULT VALUES;<br \/>\n\tGO 1000<\/font> <\/font>\n\t<\/p>\n<\/blockquote>\n<p><font face=\"verdana,geneva\"><font size=\"2\">After corrupting the database, I can reproduce the error above by running DBCC CHECKDB on it:<font size=\"+0\"><\/font><\/font><\/font><font size=\"+0\"><font face=\"verdana,geneva\" size=\"2\"> <\/font><\/p>\n<blockquote>\n<p>\n\t<font face=\"courier new,courier\"><font size=\"2\">Msg 2576, Level 16, State 1, Line 1 <br \/>\n\t<\/font><font size=\"2\">The Index Allocation Map (IAM) page (0:0) is pointed to by the previous pointer of IAM page (1:153) in object ID 0, index ID -1, partition ID 0, alloc unit ID 72057594042384384 (type Unknown), but it was not detected in the scan. <\/font><\/font>\n\t<\/p>\n<\/blockquote>\n<p><\/font><\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">The error is saying that the first IAM page in the IAM chain (page 1:153) does not have a reference from metadata. The <font face=\"courier new,courier\">sysallocunits<\/font> system table contains a link to the first IAM page, the root page, and the first page. You can see these by querying the <font face=\"courier new,courier\">sys.system_internals_allocation_units<\/font> catalog view, or you can see this blog post&nbsp; &#8211; <\/font><a href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/inside-the-storage-engine-sp_allocationmetadata-putting-undocumented-system-catalog-views-to-work\/\"><font face=\"verdana,geneva\" size=\"2\">Inside The Storage Engine: sp_AllocationMetadata &#8211; putting undocumented system catalog views to work<\/font><\/a><font face=\"verdana,geneva\" size=\"2\">. I corrupted the <font face=\"courier new,courier\">sysallocunits<\/font> table so that the link to the first IAM page of the test table was removed. The clue is the first page ID in the error &#8211; if it&#39;s a (0:0), that&#39;s the missing metadata case. For SQL 2000, this can happen if someone manually updates the sysindexes table. <\/font>\n<\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">Now what about the other case, where the IAM page itself has a corrupt header? I recreated the database again and corrupted the header of the first IAM page of the test table. Here&#39;s the output from <font face=\"courier new,courier\">DBCC CHECKDB<\/font>: <\/font>\n<\/p>\n<p><font size=\"+0\"><\/p>\n<blockquote>\n<p>\n\t<font face=\"courier new,courier\" size=\"2\">Msg 2575, Level 16, State 1, Line 1 <br \/>\n\t<\/font><font face=\"courier new,courier\" size=\"2\">The Index Allocation Map (IAM) page (1:153) is pointed to by the next pointer of IAM page (0:0) in object ID 2073058421, index ID 1, partition ID 72057594038386688, alloc unit ID 72057594042384384 (type In-row data), but it was not detected in the scan. <br \/>\n\t<\/font><font face=\"courier new,courier\" size=\"2\">Msg 7965, Level 16, State 2, Line 1 <br \/>\n\t<\/font><font face=\"courier new,courier\" size=\"2\">Table error: Could not check object ID 2073058421, index ID 1, partition ID 72057594038386688, alloc unit ID 72057594042384384 (type In-row data) due to invalid allocation (IAM) page(s). <br \/>\n\t<\/font><font size=\"+0\"><font face=\"verdana,geneva\" size=\"2\"><font face=\"courier new,courier\">Msg 8928, Level 16, State 6, Line 1<br \/>\n\t<\/font><\/font><font face=\"verdana,geneva\" size=\"2\"><font face=\"courier new,courier\">Object ID 0, index ID -1, partition ID 0, alloc unit ID 0 (type Unknown): Page (1:153) could not be processed. See other errors for details.<\/font> <\/font><\/font>\n\t<\/p>\n<\/blockquote>\n<p><\/font><\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">and a whole bunch of <\/font>\n<\/p>\n<p><font size=\"+0\"><\/font><font size=\"+0\"><\/p>\n<blockquote>\n<p>\n\t<font face=\"courier new,courier\" size=\"2\">Msg 8905, Level 16, State 1, Line 1<br \/>\n\t<\/font><font face=\"verdana,geneva\" size=\"2\"><font face=\"courier new,courier\">Extent (1:216) in database ID 21 is marked allocated in the GAM, but no SGAM or IAM has allocated it.<\/font> <\/font>\n\t<\/p>\n<\/blockquote>\n<p><\/font><\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">errors. This is because the IAM page no longer looks like an IAM page and so <font face=\"courier new,courier\">DBCC CHECKDB<\/font> can&#39;t process it as such. If I zero out the IAM page completely, <font face=\"courier new,courier\">DBCC CHECKDB<\/font> returns basically the same errors as above.&nbsp; <\/font>\n<\/p>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">I&#39;ve created&nbsp;a zipped backup of the SQL 2005 database in each case: <\/font>\n<\/p>\n<ul>\n<li>\n<div>\n\t<font face=\"verdana,geneva\" size=\"2\">Corrupt metadata: <\/font><a href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-content\/uploads\/2009\/3\/corruptiamexample1.zip\"><font face=\"verdana,geneva\" size=\"2\">CorruptIAMExample1.zip (185.51 kb)<\/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\">Corrupt IAM page header: <\/font><a href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-content\/uploads\/2009\/3\/corruptiamexample2.zip\"><font face=\"verdana,geneva\" size=\"2\">CorruptIAMExample2.zip (181.48 kb)<\/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\">Zero&#39;d IAM page: <\/font><a href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-content\/uploads\/2009\/3\/corruptiamexample3.zip\"><font face=\"verdana,geneva\" size=\"2\">CorruptIAMExample3.zip (168.68 kb)<\/font><\/a>\n\t<\/div>\n<\/li>\n<\/ul>\n<p>\n<font face=\"verdana,geneva\" size=\"2\">You&#39;ll need to do a <font face=\"courier new,courier\">RESTORE FILELISTONLY<\/font> and then maybe move the files when you restore. Have fun! <\/font><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A thread cropped up on SQLServerCentral involving IAM chain corruption (see Inside the Storage Engine: IAM pages, IAM chains, and allocation units&nbsp;for details of IAM chains). The error from DBCC CHECKDB was: Server: Msg 2576, Level 16, State 1, Line 1 IAM page (0:0) is pointed to by the previous pointer of IAM page (1:394336) [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,30,34,62,86],"tags":[],"class_list":["post-916","post","type-post","status-publish","format-standard","hentry","category-checkdb-from-every-angle","category-corruption","category-dbcc","category-on-disk-structures","category-sql-server-2008"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>IAM page corruption examples - 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\/iam-page-corruption-examples\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"IAM page corruption examples - Paul S. Randal\" \/>\n<meta property=\"og:description\" content=\"A thread cropped up on SQLServerCentral involving IAM chain corruption (see Inside the Storage Engine: IAM pages, IAM chains, and allocation units&nbsp;for details of IAM chains). The error from DBCC CHECKDB was: Server: Msg 2576, Level 16, State 1, Line 1 IAM page (0:0) is pointed to by the previous pointer of IAM page (1:394336) [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/paul\/iam-page-corruption-examples\/\" \/>\n<meta property=\"og:site_name\" content=\"Paul S. Randal\" \/>\n<meta property=\"article:published_time\" content=\"2009-03-22T06:14:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-01-02T05:12:08+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=\"3 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\/iam-page-corruption-examples\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/iam-page-corruption-examples\/\",\"name\":\"IAM page corruption examples - Paul S. Randal\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\"},\"datePublished\":\"2009-03-22T06:14:00+00:00\",\"dateModified\":\"2013-01-02T05:12:08+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/iam-page-corruption-examples\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/paul\/iam-page-corruption-examples\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/iam-page-corruption-examples\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"IAM page corruption examples\"}]},{\"@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":"IAM page corruption examples - 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\/iam-page-corruption-examples\/","og_locale":"en_US","og_type":"article","og_title":"IAM page corruption examples - Paul S. Randal","og_description":"A thread cropped up on SQLServerCentral involving IAM chain corruption (see Inside the Storage Engine: IAM pages, IAM chains, and allocation units&nbsp;for details of IAM chains). The error from DBCC CHECKDB was: Server: Msg 2576, Level 16, State 1, Line 1 IAM page (0:0) is pointed to by the previous pointer of IAM page (1:394336) [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/paul\/iam-page-corruption-examples\/","og_site_name":"Paul S. Randal","article_published_time":"2009-03-22T06:14:00+00:00","article_modified_time":"2013-01-02T05:12:08+00:00","author":"Paul Randal","twitter_misc":{"Written by":"Paul Randal","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/iam-page-corruption-examples\/","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/iam-page-corruption-examples\/","name":"IAM page corruption examples - Paul S. Randal","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website"},"datePublished":"2009-03-22T06:14:00+00:00","dateModified":"2013-01-02T05:12:08+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/iam-page-corruption-examples\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/paul\/iam-page-corruption-examples\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/iam-page-corruption-examples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/paul\/"},{"@type":"ListItem","position":2,"name":"IAM page corruption examples"}]},{"@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\/916","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=916"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/916\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/media?parent=916"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/categories?post=916"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/tags?post=916"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}