{"id":4199,"date":"2013-08-29T13:15:36","date_gmt":"2013-08-29T20:15:36","guid":{"rendered":"http:\/\/3.209.169.194\/blogs\/paul\/?p=4199"},"modified":"2017-04-13T09:49:59","modified_gmt":"2017-04-13T16:49:59","slug":"bug-dbcc-checkdb-data-purity-checks-are-skipped-for-master-and-model","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-dbcc-checkdb-data-purity-checks-are-skipped-for-master-and-model\/","title":{"rendered":"Bug: DBCC CHECKDB data purity checks are skipped for master and model"},"content":{"rendered":"<p>After going back and forth with someone with a corrupt master database, I&#8217;ve just discovered a bug. And unfortunately it goes back to SQL Server 2005 so the responsibility is mine for not realizing the problem at the time (but at least it&#8217;s not a bug in how my <em>DBCC CHECKDB<\/em> code works, it&#8217;s a bug in how master and model are created).<\/p>\n<p><em>DBCC CHECKDB<\/em> performs data purity checks to validate a column&#8217;s value is within the legal bounds of the column&#8217;s data type. It is supposed to do this for all databases created on SQL Server 2005 onward. This is based on the <em>dbi_dbccFlags<\/em> field in the database boot page being set to 2.<\/p>\n<p>In all versions, the <em>dbi_dbccFlags<\/em> field for master and model are set to zero, so no automatic data purity checks are done. I&#8217;ve notified the dev team about this and it&#8217;s been confirmed as a bug.<\/p>\n<p>Edit 9\/4\/13: I&#8217;ve heard from multiple people who&#8217;ve fixed this and found corruption issues in master &#8211; excellent! (that they found them, not that they had them :-)<\/p>\n<p>Note: If you&#8217;re using <a href=\"https:\/\/ola.hallengren.com\/\" target=\"_blank\">Ola Hallengren<\/a>&#8216;s fabulous free scripts to run your consistency checks, your <em>master<\/em> and <em>model<\/em> are set correctly as he always uses\u00a0<em>WITH DATA_PURITY<\/em>.<\/p>\n<p>I recommend that you run the following to set the value correctly on all production instances on all versions from SQL Server 2005 onward (this is a one-time operation):<\/p>\n<pre class=\"brush: sql; title: ; toolbar: true; wrap-lines: true; notranslate\" title=\"\">\r\nDBCC CHECKDB (N'master') WITH DATA_PURITY, NO_INFOMSGS;\r\nDBCC CHECKDB (N'model') WITH DATA_PURITY, NO_INFOMSGS;\r\nGO\r\n<\/pre>\n<p>You can check the value for yourself using the following code:<\/p>\n<pre class=\"brush: sql; title: ; toolbar: true; wrap-lines: true; notranslate\" title=\"\">\r\nDBCC TRACEON (3604);\r\nDBCC DBINFO (N'master');\r\nGO\r\n<\/pre>\n<p>Output from SQL Server 2012 SP1:<\/p>\n<pre class=\"brush: plain; gutter: false; title: ; toolbar: true; wrap-lines: true; notranslate\" title=\"\">\r\nDBINFO STRUCTURE:\r\n\r\nDBINFO @0x000000001E0BD400\r\n\r\ndbi_version = 706                   dbi_createVersion = 706             dbi_SEVersion = 0\r\ndbi_dvSplitPoint = 0:0:0 (0x00000000:00000000:0000)\r\ndbi_dbbackupLSN = 0:0:0 (0x00000000:00000000:0000)\r\ndbi_LastLogBackupTime = 1900-01-01 00:00:00.000\r\ndbi_nextseqnum = 1900-01-01 00:00:00.000                                 dbi_status = 0x00010008\r\ndbi_crdate = 1900-01-01 00:00:00.000dbi_dbname = master                 dbi_dbid = 1\r\ndbi_cmptlevel = 110                 dbi_masterfixups = 0                dbi_maxDbTimestamp = 4000\r\ndbi_dbbackupLSN = 0:0:0 (0x00000000:00000000:0000)                       dbi_RebuildLogs = 0\r\ndbi_differentialBaseLSN = 0:0:0 (0x00000000:00000000:0000)               dbi_RestoreFlags = 0x0000\r\ndbi_checkptLSN = 324:56:84 (0x00000144:00000038:0054)                    dbi_dbccFlags = 0\r\ndbi_COWLastLSN = 0:0:0 (0x00000000:00000000:0000)\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>After going back and forth with someone with a corrupt master database, I&#8217;ve just discovered a bug. And unfortunately it goes back to SQL Server 2005 so the responsibility is mine for not realizing the problem at the time (but at least it&#8217;s not a bug in how my DBCC CHECKDB code works, it&#8217;s a [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,22,34],"tags":[],"class_list":["post-4199","post","type-post","status-publish","format-standard","hentry","category-bugfixes","category-checkdb-from-every-angle","category-dbcc"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Bug: DBCC CHECKDB data purity checks are skipped for master and model - 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\/bug-dbcc-checkdb-data-purity-checks-are-skipped-for-master-and-model\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Bug: DBCC CHECKDB data purity checks are skipped for master and model - Paul S. Randal\" \/>\n<meta property=\"og:description\" content=\"After going back and forth with someone with a corrupt master database, I&#8217;ve just discovered a bug. And unfortunately it goes back to SQL Server 2005 so the responsibility is mine for not realizing the problem at the time (but at least it&#8217;s not a bug in how my DBCC CHECKDB code works, it&#8217;s a [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-dbcc-checkdb-data-purity-checks-are-skipped-for-master-and-model\/\" \/>\n<meta property=\"og:site_name\" content=\"Paul S. Randal\" \/>\n<meta property=\"article:published_time\" content=\"2013-08-29T20:15:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-04-13T16:49:59+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=\"2 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\/bug-dbcc-checkdb-data-purity-checks-are-skipped-for-master-and-model\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-dbcc-checkdb-data-purity-checks-are-skipped-for-master-and-model\/\",\"name\":\"Bug: DBCC CHECKDB data purity checks are skipped for master and model - Paul S. Randal\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\"},\"datePublished\":\"2013-08-29T20:15:36+00:00\",\"dateModified\":\"2017-04-13T16:49:59+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-dbcc-checkdb-data-purity-checks-are-skipped-for-master-and-model\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-dbcc-checkdb-data-purity-checks-are-skipped-for-master-and-model\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-dbcc-checkdb-data-purity-checks-are-skipped-for-master-and-model\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Bug: DBCC CHECKDB data purity checks are skipped for master and model\"}]},{\"@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":"Bug: DBCC CHECKDB data purity checks are skipped for master and model - 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\/bug-dbcc-checkdb-data-purity-checks-are-skipped-for-master-and-model\/","og_locale":"en_US","og_type":"article","og_title":"Bug: DBCC CHECKDB data purity checks are skipped for master and model - Paul S. Randal","og_description":"After going back and forth with someone with a corrupt master database, I&#8217;ve just discovered a bug. And unfortunately it goes back to SQL Server 2005 so the responsibility is mine for not realizing the problem at the time (but at least it&#8217;s not a bug in how my DBCC CHECKDB code works, it&#8217;s a [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-dbcc-checkdb-data-purity-checks-are-skipped-for-master-and-model\/","og_site_name":"Paul S. Randal","article_published_time":"2013-08-29T20:15:36+00:00","article_modified_time":"2017-04-13T16:49:59+00:00","author":"Paul Randal","twitter_misc":{"Written by":"Paul Randal","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-dbcc-checkdb-data-purity-checks-are-skipped-for-master-and-model\/","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-dbcc-checkdb-data-purity-checks-are-skipped-for-master-and-model\/","name":"Bug: DBCC CHECKDB data purity checks are skipped for master and model - Paul S. Randal","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website"},"datePublished":"2013-08-29T20:15:36+00:00","dateModified":"2017-04-13T16:49:59+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-dbcc-checkdb-data-purity-checks-are-skipped-for-master-and-model\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/paul\/bug-dbcc-checkdb-data-purity-checks-are-skipped-for-master-and-model\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-dbcc-checkdb-data-purity-checks-are-skipped-for-master-and-model\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/paul\/"},{"@type":"ListItem","position":2,"name":"Bug: DBCC CHECKDB data purity checks are skipped for master and model"}]},{"@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\/4199","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=4199"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/4199\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/media?parent=4199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/categories?post=4199"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/tags?post=4199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}