{"id":4250,"date":"2013-11-13T12:33:06","date_gmt":"2013-11-13T20:33:06","guid":{"rendered":"http:\/\/3.209.169.194\/blogs\/paul\/?p=4250"},"modified":"2020-05-03T17:06:17","modified_gmt":"2020-05-04T00:06:17","slug":"why-is-log_reuse_wait_desc-saying-log_backup-after-doing-a-log-backup","status":"publish","type":"post","link":"https:\/\/www.sqlskills.com\/blogs\/paul\/why-is-log_reuse_wait_desc-saying-log_backup-after-doing-a-log-backup\/","title":{"rendered":"Why is log_reuse_wait_desc saying LOG_BACKUP after doing a log backup?"},"content":{"rendered":"<p>(New\u00a0for 2020: we\u2019ve published a range of SQL Server interview candidate screening assessments with our partner Kandio, so you can avoid hiring an \u2018expert\u2019 who ends up causing problems. Check them out\u00a0<a href=\"https:\/\/kand.io\/tests\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.)<\/p>\n<p>(Check out my Pluralsight online training course: <em><a href=\"http:\/\/www.pluralsight.com\/training\/Courses\/TableOfContents\/sqlserver-logging\" target=\"_blank\" rel=\"noopener noreferrer\">SQL Server: Logging, Recovery, and the Transaction Log<\/a>.)<\/em><\/p>\n<p>Here&#8217;s an interesting situation that sometimes crops up: you&#8217;re performing log backups, your transaction log isn&#8217;t growing, and yet the value of <em>log_reuse_wait_desc<\/em> in <em>sys.databases<\/em> for your database says <em>LOG_BACKUP<\/em>.<\/p>\n<p>What&#8217;s going on?<\/p>\n<p>I was actually just teaching this stuff today here in our last class of the year in Chicago.<\/p>\n<p>Firstly, what is <em>log_reuse_wait_desc<\/em>? It&#8217;s a field in <em>sys.databases<\/em> that you can use to determine why the transaction log isn&#8217;t clearing (a.k.a truncating) correctly. Usually you query it when a log file is growing and you want to know why, using code like:<\/p>\n<pre class=\"brush: sql; title: ; toolbar: true; wrap-lines: true; notranslate\" title=\"\">\r\nSELECT &#x5B;log_reuse_wait_desc]\r\n\tFROM &#x5B;master].&#x5B;sys].&#x5B;databases]\r\n\tWHERE &#x5B;name] = N'Company';\r\nGO\r\n<\/pre>\n<p>You can read about all the possible values in the Books Online topic <a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/ms345414(v=sql.105).aspx\" target=\"_blank\" rel=\"noopener noreferrer\">Factors That Can Delay Log Truncation<\/a>.<\/p>\n<p>One important thing to bear in mind is that the value returned is the reason that log clearing did not clear any VLFs (Virtual Log Files &#8211; see <a href=\"https:\/\/technet.microsoft.com\/en-us\/library\/2009.02.logging.aspx\" target=\"_blank\" rel=\"noopener noreferrer\">Understanding Logging and Recovery in SQL Server<\/a>) that last time that log clearing was attempted. For instance, you may see a value of <em>ACTIVE_BACKUP_OR_RESTORE<\/em> but you know that your full backup has completed. This means that the last time log clearing was attempted, the backup was still running.<\/p>\n<p>Back to the original question. If you have a transaction log that is not growing, and you&#8217;re taking regular log backups, but the <em>log_reuse_wait_desc<\/em> remains <em>LOG_BACKUP<\/em>, this is because zero VLFs were cleared when the previous log backup was performed.<\/p>\n<p>How can that happen?<\/p>\n<p>Imagine a database where there&#8217;s very little insert\/update\/delete\/DDL activity, so in between your regular log backups there are only a few log records generated, and they&#8217;re all in the same VLF. The next log backup runs, backing up those few log records, but it can&#8217;t clear the current VLF, so can&#8217;t clear <em>log_reuse_wait_desc<\/em>. As soon as there are enough changes in the database that the current VLF fills up and the next VLF is activated, the next log backup should be able to clear the previous VLF and then the <em>log_reuse_wait_desc<\/em> will revert to <em>NOTHING<\/em>. Until the next log backup occurs and isn&#8217;t able to clear the current VLF, in which case it will go back to <em>LOG_BACKUP<\/em> again.<\/p>\n<p>So <em>LOG_BACKUP<\/em> really means &#8220;either you need to take a log backup, or the log records that were backed up were all in the current VLF and so it could not be cleared.&#8221;<\/p>\n<p>Hope this helps!<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>(New\u00a0for 2020: we\u2019ve published a range of SQL Server interview candidate screening assessments with our partner Kandio, so you can avoid hiring an \u2018expert\u2019 who ends up causing problems. Check them out\u00a0here.) (Check out my Pluralsight online training course: SQL Server: Logging, Recovery, and the Transaction Log.) Here&#8217;s an interesting situation that sometimes crops up: [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,98],"tags":[],"class_list":["post-4250","post","type-post","status-publish","format-standard","hentry","category-backuprestore","category-transaction-log"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Why is log_reuse_wait_desc saying LOG_BACKUP after doing a log backup? - 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\/why-is-log_reuse_wait_desc-saying-log_backup-after-doing-a-log-backup\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Why is log_reuse_wait_desc saying LOG_BACKUP after doing a log backup? - Paul S. Randal\" \/>\n<meta property=\"og:description\" content=\"(New\u00a0for 2020: we\u2019ve published a range of SQL Server interview candidate screening assessments with our partner Kandio, so you can avoid hiring an \u2018expert\u2019 who ends up causing problems. Check them out\u00a0here.) (Check out my Pluralsight online training course: SQL Server: Logging, Recovery, and the Transaction Log.) Here&#8217;s an interesting situation that sometimes crops up: [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlskills.com\/blogs\/paul\/why-is-log_reuse_wait_desc-saying-log_backup-after-doing-a-log-backup\/\" \/>\n<meta property=\"og:site_name\" content=\"Paul S. Randal\" \/>\n<meta property=\"article:published_time\" content=\"2013-11-13T20:33:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-05-04T00:06:17+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\/why-is-log_reuse_wait_desc-saying-log_backup-after-doing-a-log-backup\/\",\"url\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/why-is-log_reuse_wait_desc-saying-log_backup-after-doing-a-log-backup\/\",\"name\":\"Why is log_reuse_wait_desc saying LOG_BACKUP after doing a log backup? - Paul S. Randal\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#website\"},\"datePublished\":\"2013-11-13T20:33:06+00:00\",\"dateModified\":\"2020-05-04T00:06:17+00:00\",\"author\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/why-is-log_reuse_wait_desc-saying-log_backup-after-doing-a-log-backup\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqlskills.com\/blogs\/paul\/why-is-log_reuse_wait_desc-saying-log_backup-after-doing-a-log-backup\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/why-is-log_reuse_wait_desc-saying-log_backup-after-doing-a-log-backup\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqlskills.com\/blogs\/paul\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Why is log_reuse_wait_desc saying LOG_BACKUP after doing a log backup?\"}]},{\"@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":"Why is log_reuse_wait_desc saying LOG_BACKUP after doing a log backup? - 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\/why-is-log_reuse_wait_desc-saying-log_backup-after-doing-a-log-backup\/","og_locale":"en_US","og_type":"article","og_title":"Why is log_reuse_wait_desc saying LOG_BACKUP after doing a log backup? - Paul S. Randal","og_description":"(New\u00a0for 2020: we\u2019ve published a range of SQL Server interview candidate screening assessments with our partner Kandio, so you can avoid hiring an \u2018expert\u2019 who ends up causing problems. Check them out\u00a0here.) (Check out my Pluralsight online training course: SQL Server: Logging, Recovery, and the Transaction Log.) Here&#8217;s an interesting situation that sometimes crops up: [&hellip;]","og_url":"https:\/\/www.sqlskills.com\/blogs\/paul\/why-is-log_reuse_wait_desc-saying-log_backup-after-doing-a-log-backup\/","og_site_name":"Paul S. Randal","article_published_time":"2013-11-13T20:33:06+00:00","article_modified_time":"2020-05-04T00:06:17+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\/why-is-log_reuse_wait_desc-saying-log_backup-after-doing-a-log-backup\/","url":"https:\/\/www.sqlskills.com\/blogs\/paul\/why-is-log_reuse_wait_desc-saying-log_backup-after-doing-a-log-backup\/","name":"Why is log_reuse_wait_desc saying LOG_BACKUP after doing a log backup? - Paul S. Randal","isPartOf":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#website"},"datePublished":"2013-11-13T20:33:06+00:00","dateModified":"2020-05-04T00:06:17+00:00","author":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/#\/schema\/person\/ffcec826c18782e1e0adf173826a7fce"},"breadcrumb":{"@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/why-is-log_reuse_wait_desc-saying-log_backup-after-doing-a-log-backup\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlskills.com\/blogs\/paul\/why-is-log_reuse_wait_desc-saying-log_backup-after-doing-a-log-backup\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlskills.com\/blogs\/paul\/why-is-log_reuse_wait_desc-saying-log_backup-after-doing-a-log-backup\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlskills.com\/blogs\/paul\/"},{"@type":"ListItem","position":2,"name":"Why is log_reuse_wait_desc saying LOG_BACKUP after doing a log backup?"}]},{"@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\/4250","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=4250"}],"version-history":[{"count":0,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/posts\/4250\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/media?parent=4250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/categories?post=4250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlskills.com\/blogs\/paul\/wp-json\/wp\/v2\/tags?post=4250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}