{"id":688,"date":"2010-05-15T19:23:00","date_gmt":"2010-05-15T19:23:00","guid":{"rendered":"\/blogs\/paul\/post\/Bug-log-file-growth-broken-for-multiples-of-4GB.aspx"},"modified":"2017-06-09T12:18:59","modified_gmt":"2017-06-09T19:18:59","slug":"bug-log-file-growth-broken-for-multiples-of-4gb","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-log-file-growth-broken-for-multiples-of-4gb\/","title":{"rendered":"Bug: log file growth broken for multiples of 4GB"},"content":{"rendered":"<p style=\"text-align: justify;\">I was teaching an internals\/maintenance\/performance class for Microsoft DBAs this week on the Redmond campus and one of the students (thanks Crystal!) showed me a really strange bug that I&#8217;d never seen before.<\/p>\n<p style=\"text-align: justify;\">One of the things that Kimberly and I both recommend is not having transaction log VLFs be too large, with 500MB being our recommended maximum so as not to interrupt the clearing\/truncating of the log. See Kimberly&#8217;s blog post <a href=\"http:\/\/www.sqlskills.com\/blogs\/kimberly\/transaction-log-vlfs-too-many-or-too-few\/\">Transaction Log VLFs &#8211; too many or too few?<\/a> for more details.<\/p>\n<p style=\"text-align: justify;\">If you try to grow a log file by a multiple of 4GB, it will fail on the first attempt and only grow\u00a0by about\u00a031KB, with no error message. The second attempt will succeed!<\/p>\n<p style=\"text-align: justify;\">We&#8217;ve examined the SQL code and it&#8217;s a bug that the code miscalculates the growth size when the specified size is an exact multiple of 4GB. Simple type conversion error. It&#8217;s fixed in\u00a02008 R2 onward.<\/p>\n<p style=\"text-align: justify;\">This could cause you problems if you follow our advice and try to grow a log file in increments of 8GB to keep the VLF size at 500MB (a growth of 1GB or more create 16VLFs, with each VLF being 1\/16th the size of the growth).<\/p>\n<p style=\"text-align: justify;\">I tested this on 2005 SP3 and 2008 SP1.<\/p>\n<p style=\"text-align: justify;\">Here&#8217;s an example script to show what I mean. First off I&#8217;ll create a database and grow the log file to 1GB:<\/p>\n<pre class=\"brush: sql; title: ; toolbar: true; wrap-lines: true; notranslate\" title=\"\">\r\nCREATE DATABASE TestLogFileGrowth;\r\nGO\r\n\r\nALTER DATABASE TestLogFileGrowth MODIFY FILE \r\n( \r\n    NAME = TestLogFileGrowth_Log, SIZE = 1GB\r\n);\r\nGO\r\n<\/pre>\n<p style=\"text-align: justify;\">That took 30 seconds to run, performing the zero initialization of the log file (which must *always* occur &#8211; see <a href=\"https:\/\/www.sqlskills.com\/blogs\/paul\/search-engine-qa-24-why-cant-the-transaction-log-use-instant-initialization\/\">Search Engine Q&amp;A #24: Why can&#8217;t the transaction log use instant initialization?<\/a>).<\/p>\n<p>Checking the log size:<\/p>\n<pre class=\"brush: sql; title: ; toolbar: true; wrap-lines: true; notranslate\" title=\"\">\r\nDBCC SQLPERF (LOGSPACE);\r\nGO\r\n<\/pre>\n<pre class=\"brush: plain; gutter: false; title: ; toolbar: true; wrap-lines: true; notranslate\" title=\"\">\r\nDatabase Name       Log Size (MB) Log Space Used (%) Status\r\n------------------- ------------- ------------------ -------\r\n&lt;snip&gt;\r\nTestLogFileGrowth   1023.992      0.0733858          0\r\n<\/pre>\n<p>Now I&#8217;ll try to grow the log file by 4GB:<\/p>\n<pre class=\"brush: sql; title: ; toolbar: true; wrap-lines: true; notranslate\" title=\"\">\r\nALTER DATABASE TestLogFileGrowth MODIFY FILE\r\n(\r\n    NAME = TestLogFileGrowth_Log, SIZE = 5GB\r\n);\r\nGO\r\n<\/pre>\n<p>This took zero seconds. Impossible if it actually grew the log by 4GB and zero initialized it!!<\/p>\n<p>Let&#8217;s check the log size:<\/p>\n<pre class=\"brush: sql; title: ; toolbar: true; wrap-lines: true; notranslate\" title=\"\">\r\nDBCC SQLPERF (LOGSPACE);\r\nGO\r\n<\/pre>\n<pre class=\"brush: plain; gutter: false; title: ; toolbar: true; wrap-lines: true; notranslate\" title=\"\">\r\nDatabase Name      Log Size (MB) Log Space Used (%) Status\r\n------------------ ------------- ------------------ -----------\r\n&lt;snip&gt;\r\nTestLogFileGrowth  1024.234      0.07994729         0\r\n<\/pre>\n<p style=\"text-align: justify;\">Weird! It only grew by 1MB! If I try the grow again (and as long as I don&#8217;t specify a size that&#8217;s an exact multiple of 4GB from the current size), it takes a couple of minutes and grows correctly.<\/p>\n<p>Don&#8217;t be surprised if you see this. (Note: the bug is fixed from SQL Server 2008 R2 onward.)<\/p>\n<p>Cheers<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was teaching an internals\/maintenance\/performance class for Microsoft DBAs this week on the Redmond campus and one of the students (thanks Crystal!) showed me a really strange bug that I&#8217;d never seen before. One of the things that Kimberly and I both recommend is not having transaction log VLFs be too large, with 500MB being [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[98],"tags":[],"class_list":["post-688","post","type-post","status-publish","format-standard","hentry","category-transaction-log"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Bug: log file growth broken for multiples of 4GB - 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-log-file-growth-broken-for-multiples-of-4gb\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Bug: log file growth broken for multiples of 4GB - Paul S. Randal\" \/>\n<meta property=\"og:description\" content=\"I was teaching an internals\/maintenance\/performance class for Microsoft DBAs this week on the Redmond campus and one of the students (thanks Crystal!) showed me a really strange bug that I&#8217;d never seen before. One of the things that Kimberly and I both recommend is not having transaction log VLFs be too large, with 500MB being [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-log-file-growth-broken-for-multiples-of-4gb\/\" \/>\n<meta property=\"og:site_name\" content=\"Paul S. Randal\" \/>\n<meta property=\"article:published_time\" content=\"2010-05-15T19:23:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-06-09T19:18: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-log-file-growth-broken-for-multiples-of-4gb\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-log-file-growth-broken-for-multiples-of-4gb\/\",\"name\":\"Bug: log file growth broken for multiples of 4GB - Paul S. Randal\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\"},\"datePublished\":\"2010-05-15T19:23:00+00:00\",\"dateModified\":\"2017-06-09T19:18:59+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-log-file-growth-broken-for-multiples-of-4gb\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-log-file-growth-broken-for-multiples-of-4gb\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-log-file-growth-broken-for-multiples-of-4gb\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Bug: log file growth broken for multiples of 4GB\"}]},{\"@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: log file growth broken for multiples of 4GB - 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-log-file-growth-broken-for-multiples-of-4gb\/","og_locale":"en_US","og_type":"article","og_title":"Bug: log file growth broken for multiples of 4GB - Paul S. Randal","og_description":"I was teaching an internals\/maintenance\/performance class for Microsoft DBAs this week on the Redmond campus and one of the students (thanks Crystal!) showed me a really strange bug that I&#8217;d never seen before. One of the things that Kimberly and I both recommend is not having transaction log VLFs be too large, with 500MB being [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-log-file-growth-broken-for-multiples-of-4gb\/","og_site_name":"Paul S. Randal","article_published_time":"2010-05-15T19:23:00+00:00","article_modified_time":"2017-06-09T19:18: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-log-file-growth-broken-for-multiples-of-4gb\/","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-log-file-growth-broken-for-multiples-of-4gb\/","name":"Bug: log file growth broken for multiples of 4GB - Paul S. Randal","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website"},"datePublished":"2010-05-15T19:23:00+00:00","dateModified":"2017-06-09T19:18:59+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-log-file-growth-broken-for-multiples-of-4gb\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/paul\/bug-log-file-growth-broken-for-multiples-of-4gb\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/bug-log-file-growth-broken-for-multiples-of-4gb\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/paul\/"},{"@type":"ListItem","position":2,"name":"Bug: log file growth broken for multiples of 4GB"}]},{"@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\/688","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=688"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/688\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/media?parent=688"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/categories?post=688"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/tags?post=688"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}